Commit 3a3811b1 authored by Ayush Tiwari's avatar Ayush Tiwari

[hal_json_style]: Add case for no link for URL columns

Also, remove the test from expected Failure for this case.
parent f15499b2
...@@ -1963,6 +1963,10 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None, ...@@ -1963,6 +1963,10 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
selection_name=catalog_kw['selection_name'], selection_name=catalog_kw['selection_name'],
column_id=select) column_id=select)
except AttributeError as e: except AttributeError as e:
# In case the URL method is invalid or empty, we expect to have no link
# for the column to maintain compatibility with old UI, hence we create
# an empty url_parameter_dict for these cases.
url_parameter_dict = {}
if url_column_dict[select]: if url_column_dict[select]:
log("Invalid URL method {!s} on column {}".format(url_column_dict[select], select), level=800) log("Invalid URL method {!s} on column {}".format(url_column_dict[select], select), level=800)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import transaction import transaction
from zExceptions import Unauthorized from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from unittest import skip, expectedFailure from unittest import skip
from functools import wraps from functools import wraps
from ZPublisher.HTTPRequest import HTTPRequest from ZPublisher.HTTPRequest import HTTPRequest
...@@ -1378,7 +1378,6 @@ return url ...@@ -1378,7 +1378,6 @@ return url
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList( self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
field_url_columns = '') field_url_columns = '')
@expectedFailure
@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',
...@@ -1386,6 +1385,7 @@ return url ...@@ -1386,6 +1385,7 @@ return url
@simulate('Test_listProducts', '*args, **kwargs', """ @simulate('Test_listProducts', '*args, **kwargs', """
return context.getPortalObject().foo_module.contentValues() return context.getPortalObject().foo_module.contentValues()
""") """)
@changeSkin('Hal')
def test_getHateoasDocument_listbox_check_url_column_no_url(self): def test_getHateoasDocument_listbox_check_url_column_no_url(self):
# pass custom list method which expect input arguments # pass custom list method which expect input arguments
self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList( self.portal.foo_module.FooModule_viewFooList.listbox.ListBox_setPropertyList(
......
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