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
Eteri
erp5
Commits
710e975a
Commit
710e975a
authored
May 14, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style]: Add test to check keys and values in url_value dict
parent
caf8eb1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+52
-0
No files found.
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
710e975a
...
@@ -1410,6 +1410,58 @@ return context.getPortalObject().foo_module.contentValues()
...
@@ -1410,6 +1410,58 @@ return context.getPortalObject().foo_module.contentValues()
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
ListBox_setPropertyList
(
self
.
portal
.
foo_module
.
FooModule_viewFooList
.
listbox
.
ListBox_setPropertyList
(
field_url_columns
=
''
)
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,
'reset': 1
}
}
return url
"""
)
@
changeSkin
(
'Hal'
)
def
test_getHateoasDocument_listbox_check_url_column_option_parameters
(
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'
].
keys
(),
[
u'url'
,
u'reset'
])
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"'
)
@
simulate
(
'Test_listObjects'
,
'*args, **kwargs'
,
"""
@
simulate
(
'Test_listObjects'
,
'*args, **kwargs'
,
"""
...
...
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