Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax response top-level root validator #903

Conversation

CasperWA
Copy link
Member

Fixes #902.

Add test that checks a Response can be initialized with "null" values for the "required" top-level fields, while still raising a ValidationError if the "required" top-level fields are left out.

Note: See the issue to discuss whether this fix should be implemented or not - this PR is simply here to be able to fix the issue if we agree that it is an issue and currently violates the specification.

Add test that checks a `Response` can be initialized with "null" values
for the "required" top-level fields, while still raising a
`ValidationError` if the "required" top-level fields are left out.
@codecov
Copy link

codecov bot commented Aug 10, 2021

Codecov Report

Merging #903 (6db2727) into master (1d8fc8e) will increase coverage by 0.03%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #903      +/-   ##
==========================================
+ Coverage   92.74%   92.77%   +0.03%     
==========================================
  Files          67       67              
  Lines        3763     3765       +2     
==========================================
+ Hits         3490     3493       +3     
+ Misses        273      272       -1     
Flag Coverage Δ
project 92.77% <75.00%> (+0.03%) ⬆️
validator 92.77% <75.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/models/responses.py 97.61% <50.00%> (ø)
optimade/models/optimade_json.py 95.78% <66.66%> (ø)
optimade/models/jsonapi.py 93.49% <100.00%> (+0.93%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d8fc8e...6db2727. Read the comment docs.

@ml-evs
Copy link
Member

ml-evs commented Aug 10, 2021

Just FYI you might need to change the validator for the Success model too, as that overwrites this validator

This related mainly to the top-level fields and their presence or not,
instead of validating their content, which is too strict.
The exception being the top-level field `errors`.

Also added a lot of EOL periods to descriptions and doc-strings.
Copy link
Contributor

@JPBergsma JPBergsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems Ok to me.

@CasperWA CasperWA merged commit 1d951bf into Materials-Consortia:master Aug 11, 2021
@CasperWA CasperWA deleted the fix_902_too-strict-top-level-validator branch August 11, 2021 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too strict validator for top-level fields
3 participants