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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
preetwinder
erp5
Commits
13fa98dc
Commit
13fa98dc
authored
Jun 26, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Add test for failing dialog with HTTP400 and field errors
parent
b3dc32f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+35
-2
No files found.
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
13fa98dc
...
...
@@ -50,7 +50,7 @@ def simulate(script_id, params_string, code_string):
def
createIndexedDocument
():
def
decorator
(
func
):
def
wrapped
(
self
,
*
args
,
**
kwargs
):
self
.
_makeDocument
(
)
kwargs
.
update
(
document
=
self
.
_makeDocument
()
)
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
return
func
(
self
,
*
args
,
**
kwargs
)
...
...
@@ -1062,7 +1062,7 @@ class TestERP5Document_getHateoas_mode_worklist(ERP5HALJSONStyleSkinsMixin):
'return "application/hal+json"'
)
@
createIndexedDocument
()
@
changeSkin
(
'Hal'
)
def
test_getHateoasWorklist_default_view
(
self
):
def
test_getHateoasWorklist_default_view
(
self
,
document
):
# self._makeDocument()
fake_request
=
do_fake_request
(
"GET"
)
result
=
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
(
...
...
@@ -1203,3 +1203,36 @@ return msg"
)
result_dict
=
json
.
loads
(
result
)
self
.
assertEqual
(
result_dict
[
'title'
],
'Foo_zhongwen'
)
class
TestERP5Action_getHateoas
(
ERP5HALJSONStyleSkinsMixin
):
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/foo"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
@
createIndexedDocument
()
def
test_getHateoasDialog_dialog_failure
(
self
,
document
):
"""Test an dialog on Foo object with empty required for a failure.
Expected behaviour is response Http 400 with field errors.
"""
fake_request
=
do_fake_request
(
"POST"
)
# user form fields (no need to set meta-fields because we pass them directly to script)
fake_request
.
set
(
'field_your_workflow_action'
,
'custom_dialog_required_action'
)
fake_request
.
set
(
'field_your_comment'
,
'My comment'
)
fake_request
.
set
(
'field_your_custom_workflow_variable'
,
''
)
# empty required field!
# call the standard dialog submit script
response
=
document
.
Base_callDialogMethod
(
REQUEST
=
fake_request
,
dialog_method
=
'Foo_doNothing'
,
# 'Workflow_statusModify' would lead us to different code path,
dialog_id
=
'Foo_viewCustomWorkflowRequiredActionDialog'
,
)
response
=
json
.
loads
(
response
)
self
.
assertEqual
(
fake_request
.
RESPONSE
.
status
,
400
)
self
.
assertIn
(
'your_custom_workflow_variable'
,
response
,
"Invalid field '{}' must be in the response {!s}"
.
format
(
'your_custom_workflow_variable'
,
response
))
self
.
assertIn
(
'error_text'
,
response
[
'your_custom_workflow_variable'
],
"Invalid field must contain error message"
)
self
.
assertGreater
(
len
(
response
[
'your_custom_workflow_variable'
][
'error_text'
]),
0
,
"Error message must not be empty"
)
\ No newline at end of file
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