Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Allow empty null response #258

Merged
merged 1 commit into from
Apr 10, 2022
Merged

Conversation

radekjg
Copy link
Contributor

@radekjg radekjg commented Apr 9, 2022

Empty response worked only if response.json returned something.
But if a response data is not json-serializable schema tester raises an error.

@codecov
Copy link

codecov bot commented Apr 9, 2022

Codecov Report

Merging #258 (a1f810c) into master (53e6b88) will not change coverage.
The diff coverage is 100.0%.

@@           Coverage Diff           @@
##           master     #258   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files           8        8           
  Lines         476      476           
  Branches       96       96           
=======================================
  Hits          476      476           
Impacted Files Coverage Δ
openapi_tester/schema_tester.py 100.0% <100.0%> (ø)

@sondrelg
Copy link
Member

sondrelg commented Apr 9, 2022

Trying to review on a very small screen, so need some help understanding the changes made: do you want the library to support a case like this?

schema_tester = SchemaTester()

def my_test(client):
    response = client.get('api/v1/...')
    assert response.status_code == 204
    schema_tester.validate_response(response=response, ...)

will this change allow you to detect a missing response? I.e., will the test fail if response.data is missing and the schema documents an actual response?

Seems like a good change in general 👍

@radekjg
Copy link
Contributor Author

radekjg commented Apr 9, 2022

If schema documents a response, the if before (that gets the content key will fail because response content won't match the spec)

@sondrelg
Copy link
Member

sondrelg commented Apr 9, 2022

This looks good @radowit 👍 Would you mind rebasing on master and updating the version in pyproject.toml to v2.0.1? I'll release a new version shortly after

@sondrelg
Copy link
Member

Thanks @radowit!

@sondrelg sondrelg merged commit d9f108d into snok:master Apr 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants