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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
e306930e
Commit
e306930e
authored
Nov 27, 2023
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_action_information_api: validate tests against an input schema
parent
bb97411f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
11 deletions
+50
-11
bt5/erp5_action_information_api/TestTemplateItem/portal_components/test.erp5.testActionInformationAPI.py
...m/portal_components/test.erp5.testActionInformationAPI.py
+50
-11
No files found.
bt5/erp5_action_information_api/TestTemplateItem/portal_components/test.erp5.testActionInformationAPI.py
View file @
e306930e
...
...
@@ -71,13 +71,52 @@ class TestActionInformationAPI(ERP5TypeTestCase):
action
.
edit
(
title
=
action_id
,
reference
=
action_id
,
action
=
"string:${object_url}/"
+
action_
script
,
action
=
"string:${object_url}/"
+
action_
id
,
action_type
=
self
.
object_api_value
.
getRelativeUrl
(),
float_index
=
7.0
,
)
self
.
tic
()
self
.
commit
()
json_form
=
self
.
portal
.
portal_callables
.
get
(
action_id
,
None
)
if
not
json_form
:
json_form
=
self
.
portal
.
portal_callables
.
newContent
(
portal_type
=
"JSON Form"
,
id
=
action_id
,
)
json_form
.
edit
(
title
=
action_id
,
reference
=
action_id
,
after_method_id
=
action_script
,
)
# Note: text content is input schema
json_form
.
setTextContent
(
"""{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "",
"title": "Update Person email",
"description": "Update email address of a Person",
"type": "object",
"properties": {
"email": {
"title": "Email address",
"type": "string",
"format": "email"
},
"reference": {
"title": "Unique identifier",
"type": "string"
}
},
"required": [
"email",
"reference"
]
}"""
)
json_form
.
setOutputSchema
(
"{}"
)
self
.
tic
()
self
.
commit
()
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
action_script
,
...
...
@@ -141,7 +180,7 @@ return {"status": 200}""")
user
=
"ERP5TypeTestCase"
)
def
test_hyperdocument_
script
(
self
):
def
test_hyperdocument_
cedric
(
self
):
self
.
setupAiApi
()
response
=
self
.
loggedInRequest
(
"/api"
,
"GET"
,
{})
...
...
@@ -152,7 +191,15 @@ return {"status": 200}""")
self
.
assertTrue
(
"Person_updateEmail/getInputJSONSchema"
in
response_json
[
"links"
][
0
][
"$schemaRequest"
])
self
.
assertTrue
(
"Person_updateEmail/getOutputJSONSchema"
in
response_json
[
"links"
][
0
][
"$schemaResponse"
])
def
test_update_script
(
self
):
def
test_hyperdocument_openapi
(
self
):
self
.
setupOpenApi
()
response
=
self
.
loggedInRequest
(
"/api"
,
"GET"
,
{})
response_json
=
json
.
loads
(
response
.
getBody
())
self
.
assertEqual
(
response_json
[
"openapi"
],
"3.0.2"
)
def
test_update_cedric
(
self
):
self
.
setupAiApi
()
person
=
self
.
portal
.
person_module
.
newContent
(
...
...
@@ -173,11 +220,3 @@ return {"status": 200}""")
self
.
assertEqual
(
response
.
getBody
(),
json
.
dumps
({
"status"
:
200
},
indent
=
2
))
self
.
assertEqual
(
response
.
getStatus
(),
200
)
self
.
assertEqual
(
person
.
getDefaultEmailUrlString
(),
"alice@looking.glass"
)
def
test_hyperdocument_openapi
(
self
):
self
.
setupOpenApi
()
response
=
self
.
loggedInRequest
(
"/api"
,
"GET"
,
{})
response_json
=
json
.
loads
(
response
.
getBody
())
self
.
assertEqual
(
response_json
[
"openapi"
],
"3.0.2"
)
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