Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
00958618
Commit
00958618
authored
Apr 13, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json_style]: Add tests for new JSON format and url value in hal_json_style
parent
53da1cd7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
145 additions
and
0 deletions
+145
-0
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+145
-0
No files found.
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
00958618
...
@@ -1187,6 +1187,151 @@ return context.getPortalObject().foo_module.contentValues()
...
@@ -1187,6 +1187,151 @@ return context.getPortalObject().foo_module.contentValues()
# There is a count method on this listbox
# There is a count method on this listbox
self.assertEqual(result_dict['
_embedded
']['
count
'], 0)
self.assertEqual(result_dict['
_embedded
']['
count
'], 0)
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
args
,
**
kwargs
',
'
return
"application/hal+json"')
@simulate('
Test_listProducts
', '
*
args
,
**
kwargs
', """
return context.getPortalObject().foo_module.contentValues()
""")
@simulate('
Base_getUrl
', '
url_dict
=
False
,
*
args
,
**
kwargs
', """
if url_dict:
jio_key = context.getRelativeUrl()
return {
'
command
': '
push_history
',
'
options
': {
'
jio_key
': jio_key,
'
editable
': False
},
'
view_kw
': {
'
view
': '
metadata
',
'
jio_key
': jio_key,
'
extra_param_json
': {'
reset
': 1},
}
}
return '
%
s
/
Base_viewMetadata
?
reset
:
int
=
1
' % context.getRelativeUrl()
""")
@changeSkin('
Hal
')
def test_getHateoasDocument_listbox_check_url_column_different_view(self):
# pass custom list method which expect input arguments
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = ['
modification_date
|
Base_getUrl
',])
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="search",
list_method='
Test_listProducts
',
select_list=['
id
', '
title
', '
creation_date
', '
modification_date
'],
form_relative_url='
portal_skins
/
erp5_ui_test
/
FooModule_viewFooList
/
listbox
')
result_dict = json.loads(result)
# Test the URL value
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
command
'], '
push_history
')
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
jio_key
'], self.portal.foo_module.contentValues()[0].getRelativeUrl())
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
editable
'], False)
self.assertIn('
metadata
', result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
view
'])
self.assertIn('
extra_param_json
', result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
view
'])
self.assertIn(self.portal.foo_module.contentValues()[0].getRelativeUrl().replace("/", "%2F"), result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
view
'])
# Test the field_gadget_param
self.assertTrue(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
'])
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
']['
type
'], '
DateTimeField
')
# Reset the url_columns of the listbox
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = '')
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
args
,
**
kwargs
',
'
return
"application/hal+json"')
@simulate('
Base_getUrl
', '
url_dict
=
False
,
*
args
,
**
kwargs
', """
url = "https://officejs.com"
if url_dict:
return {'
command
': '
raw
',
'
options
': {
'
url
': url
}
}
return url
""")
@changeSkin('
Hal
')
def test_getHateoasDocument_listbox_check_url_column_absolute_url_with_field_rendering(self):
# pass custom list method which expect input arguments
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = ['
modification_date
|
Base_getUrl
',])
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="search",
list_method='
objectValues
',
select_list=['
id
', '
title
', '
creation_date
', '
modification_date
'],
form_relative_url='
portal_skins
/
erp5_ui_test
/
FooModule_viewFooList
/
listbox
')
result_dict = json.loads(result)
# Test the URL value
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
command
'], '
raw
')
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
url_value
']['
options
']['
url
'], '
https
:
//
officejs
.
com
')
# Test the field_gadget_param
self.assertTrue(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
'])
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
']['
type
'], '
DateTimeField
')
# Reset the url_columns of the listbox
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = '')
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
args
,
**
kwargs
',
'
return
"application/hal+json"')
@simulate('
Test_listProducts
', '
*
args
,
**
kwargs
', """
return context.getPortalObject().foo_module.contentValues()
""")
@simulate('
Base_getUrl
', '
url_dict
=
False
,
*
args
,
**
kwargs
', """
url = "https://officejs.com"
if url_dict:
return {'
command
': '
raw
',
'
options
': {
'
url
': url
}
}
return url
""")
@changeSkin('
Hal
')
def test_getHateoasDocument_listbox_check_url_column_absolute_url_without_field_rendering(self):
# pass custom list method which expect input arguments
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = ['
title
|
Base_getUrl
',])
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="search",
list_method='
Test_listProducts
',
select_list=['
id
', '
title
', '
creation_date
', '
modification_date
'],
form_relative_url='
portal_skins
/
erp5_ui_test
/
FooModule_viewFooList
/
listbox
')
result_dict = json.loads(result)
# Test the URL value
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
title
']['
url_value
']['
command
'], '
raw
')
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
title
']['
url_value
']['
options
']['
url
'], '
https
:
//
officejs
.
com
')
# Test if the value of the column is with right key
self.assertTrue(result_dict['
_embedded
']['
contents
'][0]['
title
']['
default
'])
# Test if the field_gadget_param even if there is no url_value
self.assertTrue(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
'])
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]['
modification_date
']['
field_gadget_param
']['
type
'], '
DateTimeField
')
# Test that creation_date doesn'
t
has
`url_value`
dict
in
it
self
.
assertNotIn
(
'url_value'
,
result_dict
[
'_embedded'
][
'contents'
][
0
][
'modification_date'
])
# Reset the url_columns of the listbox
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
ListBox_setPropertyList
(
field_url_columns
=
''
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment