Commit f15499b2 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

[hal_json] Fix edge cases in tests (and unused import)

parent 81883086
...@@ -777,12 +777,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -777,12 +777,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
) )
result_dict = json.loads(result) result_dict = json.loads(result)
_, group_fields = result_dict['group_list'][-1] _, group_fields = result_dict['group_list'][-1]
field_names = [field_name for field_name, field_type in group_fields] field_names = [field_name for field_name, _ in group_fields]
self.assertIn("form_id", field_names) self.assertIn("form_id", field_names)
self.assertIn("dialog_id", field_names) self.assertIn("dialog_id", field_names)
# no need for dialog_method because that one is hardcoded in javascript # no need for dialog_method because that one is hardcoded in javascript
@simulate('Base_getRequestUrl', '*args, **kwargs', @simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"') 'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs', @simulate('Base_getRequestHeader', '*args, **kwargs',
...@@ -974,6 +973,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -974,6 +973,11 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
"application/hal+json" "application/hal+json"
) )
result_dict = json.loads(result) result_dict = json.loads(result)
if isinstance(result_dict['_links']['action_object_jio_action'], dict):
object_jio_action = result_dict['_links']['action_object_jio_action']
self.assertTrue(object_jio_action['templated'])
self.assertTrue("{&" in object_jio_action['href'])
else:
for object_jio_action in result_dict['_links']['action_object_jio_action']: for object_jio_action in result_dict['_links']['action_object_jio_action']:
# the link is a template # the link is a template
self.assertTrue(object_jio_action['templated']) self.assertTrue(object_jio_action['templated'])
...@@ -1428,6 +1432,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -1428,6 +1432,7 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
Practically, because we code in python, it can be any object. Practically, because we code in python, it can be any object.
""" """
fake_request = do_fake_request("GET") fake_request = do_fake_request("GET")
document_list = sorted(document_list, key=lambda d: d.getId())
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas( result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request, REQUEST=fake_request,
mode="search", mode="search",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment