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
Labels
Merge Requests
140
Merge Requests
140
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
adfe6e53
Commit
adfe6e53
authored
May 18, 2021
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: consider only functions and avoid methods in select_list
parent
ccdf3ddb
Pipeline
#15582
failed with stage
in 0 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+2
-1
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+28
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
adfe6e53
...
...
@@ -1864,7 +1864,8 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
else
:
catalog_kw
[
'group_by_list'
]
=
[
str
(
group_by
)]
# Include select, as user may want to count
catalog_kw
[
"select_list"
]
=
select_list
# For now, consider only functions, for example, count(column_name) or COUNT(column name)
catalog_kw
[
"select_list"
]
=
[
x
for
x
in
select_list
if
re
.
match
(
r"^\
D+
\(\
w+
\)$"
,
x
)]
if
limit
:
catalog_kw
[
"limit"
]
=
limit
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
adfe6e53
...
...
@@ -1427,6 +1427,34 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
# No count if not in the listbox context currently
self.assertEqual(result_dict['
_embedded
'].get('
count
', None), None)
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
args
,
**
kwargs
',
'
return
"application/hal+json"')
@changeSkin('
Hal
')
def test_getHateoas_select_list_avoid_accessor(self):
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(
REQUEST=fake_request,
mode="search",
query="id:=hateoas AND uid:=%s" % self.portal.web_site_module.hateoas.getUid(),
select_list=["count(validation_state)",
"getTranslatedValidationStateTitle",],
group_by="validation_state"
)
self.assertEquals(fake_request.RESPONSE.status, 200)
self.assertEquals(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['
_select_list
'],
["count(validation_state)", "getTranslatedValidationStateTitle"])
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]["getTranslatedValidationStateTitle"], "Published")
self.assertEqual(result_dict['
_embedded
']['
contents
'][0]["count(validation_state)"], 1)
@simulate('
Base_getRequestUrl
', '
*
args
,
**
kwargs
',
'
return
"http://example.org/bar"')
@simulate('
Base_getRequestHeader
', '
*
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