Skip to content

Commit

Permalink
post processing in save_request_and_response_for_docs method
Browse files Browse the repository at this point in the history
  • Loading branch information
kakshay21 committed Jan 29, 2018
1 parent 27af040 commit 4537364
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/plone/restapi/tests/test_documentation.py
Expand Up @@ -121,6 +121,23 @@ def save_request_and_response_for_docs(name, response):
# Pretty print JSON request body
if content_type == 'application/json':
json_body = json.loads(response.request.body)
# Removing inconsistency in document. See #285
if 'source' in json_body:
reqs = json_body['source']
if isinstance(reqs, unicode) or isinstance(reqs, str):
reqs = reqs.replace('55001', '8080')
reqs = reqs.replace('plone', 'Plone')
elif isinstance(reqs, list):
for i in range(len(reqs)):
reqs[i] = reqs[i].replace('55001', '8080')
reqs[i] = reqs[i].replace('plone', 'Plone')
json_body['source'] = reqs
elif 'id' in json_body:
reqs = json_body['source']
if isinstance(reqs, str) or isinstance(reqs, unicode):
reqs = reqs.replace('55001', '8080')
reqs = reqs.replace('plone', 'Plone')
json_body['source'] = reqs
body = pretty_json(json_body)
# Make sure Content-Length gets updated, just in case we
# ever decide to dump that header
Expand Down

0 comments on commit 4537364

Please sign in to comment.