Commit ec59c24d authored by Romain Courteaud's avatar Romain Courteaud

erp5_hal_json_style: WIP reproduce acquisition issue

parent 71f0dec8
Pipeline #38225 failed with stage
in 0 seconds
...@@ -2449,6 +2449,39 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id ...@@ -2449,6 +2449,39 @@ return context.getPortalObject().portal_catalog(portal_type='Foo', sort_on=[('id
result_dict['_embedded']['contents'][0]["title"], result_dict['_embedded']['contents'][0]["title"],
u'\ufffd\ufffd\ufffd' if six.PY2 else u'\udce9\udccf\udcf3\udcaf') u'\ufffd\ufffd\ufffd' if six.PY2 else u'\udce9\udccf\udcf3\udcaf')
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@createIndexedDocument(quantity=1)
@changeSkin('Hal')
def test_getHateoas_cell_acquisition_context(self, document):
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request,
mode="search",
select_list=["id", "absolute_url"],
query='uid:"%s"' % document.getUid(),
)
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"})
self.assertEqual(result_dict['_debug'], "search")
self.assertEqual(result_dict['_limit'], 10)
self.assertEqual(result_dict['_query'], 'uid:"%s"' % document.getUid())
self.assertEqual(result_dict['_local_roles'], None)
self.assertEqual(result_dict['_select_list'], ["id", "absolute_url"])
self.assertEqual(len(result_dict['_embedded']['contents']), 1)
absolute_url = result_dict['_embedded']['contents'][0]["absolute_url"]
self.assertEqual(str(absolute_url), '%s/%s' % (self.portal.web_site_module.hateoas.absolute_url(), document.getRelativeUrl()))
self.assertEqual(result_dict['_embedded']['contents'][0]["_links"]["self"]["href"], "urn:jio:get:%s" % relative_url)
# No count if not in the listbox context currently
self.assertEqual(result_dict['_embedded'].get('count', None), None)
class TestERP5Person_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin): class TestERP5Person_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
"""Test HAL_JSON operations on cataloged Persons and other allowed content types of Person Module.""" """Test HAL_JSON operations on cataloged Persons and other allowed content types of Person Module."""
......
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