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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
erp5
Commits
30bdb3d3
Commit
30bdb3d3
authored
Oct 11, 2023
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_api_style: update tests for new API
parent
c0870211
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
29 deletions
+13
-29
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
...lateItem/portal_components/document.erp5.jIOWebSection.py
+0
-4
bt5/erp5_api_style/TestTemplateItem/portal_components/test.erp5.testJioApiStyle.py
...mplateItem/portal_components/test.erp5.testJioApiStyle.py
+13
-25
No files found.
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
View file @
30bdb3d3
...
...
@@ -122,8 +122,6 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
# Register current web site physical path for later URL generation
if
not
self
.
REQUEST
.
get
(
"live_test"
,
False
)
and
self
.
REQUEST
.
REQUEST_METHOD
==
"GET"
:
return
self
.
_asjIOStyle
(
mode
=
"get"
,
text_content
=
self
.
REQUEST
.
form
.
keys
()[
0
])
return
self
.
_asjIOStyle
(
mode
=
"get"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
security
.
declareProtected
(
Permissions
.
View
,
'post'
)
...
...
@@ -151,6 +149,4 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
# Register current web site physical path for later URL generation
if
not
self
.
REQUEST
.
get
(
"live_test"
,
False
)
and
self
.
REQUEST
.
REQUEST_METHOD
==
"GET"
:
return
self
.
_asjIOStyle
(
mode
=
"allDocs"
,
text_content
=
self
.
REQUEST
.
form
.
keys
()[
0
])
return
self
.
_asjIOStyle
(
mode
=
"allDocs"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
bt5/erp5_api_style/TestTemplateItem/portal_components/test.erp5.testJioApiStyle.py
View file @
30bdb3d3
...
...
@@ -757,11 +757,11 @@ result_list = context.getPortalObject().portal_catalog(
select_list=("relative_url", "portal_type", "title"),
**search_kw
)
return [{
return
json.dumps(
[{
"id": x.relative_url,
"portal_type": x.portal_type,
"title": x.title,
} for x in result_list]
} for x in result_list]
)
"""
%
(
self
.
id_template
))
def
test_action_all_docs_success_one_action_one_result
(
self
):
...
...
@@ -785,14 +785,12 @@ return [{
"title": "%s"
}"""
%
self
.
id_template
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
1
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
1
,
len
(
response
))
self
.
assertEqual
({
u"id"
:
person
.
getRelativeUrl
().
decode
(),
u"portal_type"
:
person
.
getPortalType
().
decode
(),
u"title"
:
person
.
getTitle
().
decode
(),
},
response
[
"result_list"
][
0
])
},
response
[
0
])
def
test_action_all_docs_success_one_action_no_result
(
self
):
"""
...
...
@@ -815,9 +813,7 @@ return [{
"title": "BAR"
}"""
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
0
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
0
,
len
(
response
))
def
createUpdateScriptjIOWebSectionSearchOrganisationFromJSON
(
self
):
createZODBPythonScript
(
...
...
@@ -839,11 +835,11 @@ result_list = context.getPortalObject().portal_catalog(
select_list=("relative_url", "portal_type", "title"),
**search_kw
)
return [{
return
json.dumps(
[{
"id": x.relative_url,
"portal_type": x.portal_type,
"title": x.title,
} for x in result_list]
} for x in result_list]
)
"""
)
def
test_action_all_docs_success_two_actions_with_result
(
self
):
...
...
@@ -879,14 +875,12 @@ return [{
"title": "%s"
}"""
%
self
.
id_template
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
1
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
1
,
len
(
response
))
self
.
assertEqual
({
u"id"
:
organisation
.
getRelativeUrl
().
decode
(),
u"portal_type"
:
organisation
.
getPortalType
().
decode
(),
u"title"
:
organisation
.
getTitle
().
decode
(),
},
response
[
"result_list"
][
0
])
},
response
[
0
])
# Check Second action
response
=
json
.
loads
(
self
.
allDocsToApi
(
"""{
...
...
@@ -894,14 +888,12 @@ return [{
"title": "%s"
}"""
%
self
.
id_template
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
1
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
1
,
len
(
response
))
self
.
assertEqual
({
u"id"
:
person
.
getRelativeUrl
().
decode
(),
u"portal_type"
:
person
.
getPortalType
().
decode
(),
u"title"
:
person
.
getTitle
().
decode
(),
},
response
[
"result_list"
][
0
])
},
response
[
0
])
def
test_action_all_docs_success_two_actions_with_no_result
(
self
):
"""
...
...
@@ -936,9 +928,7 @@ return [{
"title": "BAR"
}"""
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
0
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
0
,
len
(
response
))
# Check Second action
response
=
json
.
loads
(
self
.
allDocsToApi
(
"""{
...
...
@@ -946,9 +936,7 @@ return [{
"title": "BAR"
}"""
))
if
not
"result_list"
in
response
:
raise
ValueError
(
"Unexcpected Answer %s"
%
response
)
self
.
assertEqual
(
0
,
len
(
response
[
"result_list"
]))
self
.
assertEqual
(
0
,
len
(
response
))
def
test_action_all_docs_no_action_matches
(
self
):
"""
...
...
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