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

feat: validate default values #1075

Merged
merged 4 commits into from
Apr 23, 2023

Conversation

sisp
Copy link
Member

@sisp sisp commented Apr 3, 2023

I've added validation of default values which revealed an error in one of the test cases and some general weakness in the answer parsing/casting. In particular, a type: str/int/float/bool question could have None as its default value and Copier didn't complain for several reasons:

Note: This PR requires #958 to be merged first. The test suite fails right now but passes for me after merging #958 locally.

@sisp sisp force-pushed the feat/validate-default-values branch from 50544e7 to 7d90d7d Compare April 7, 2023 18:23
@codecov
Copy link

codecov bot commented Apr 7, 2023

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.52%. Comparing base (eee609d) to head (cb2e386).
Report is 429 commits behind head on master.

Files Patch % Lines
copier/user_data.py 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1075      +/-   ##
==========================================
- Coverage   96.59%   96.52%   -0.08%     
==========================================
  Files          45       45              
  Lines        3699     3710      +11     
==========================================
+ Hits         3573     3581       +8     
- Misses        126      129       +3     
Flag Coverage Δ
unittests 96.52% <91.66%> (-0.08%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sisp sisp marked this pull request as ready for review April 7, 2023 18:36
Copy link
Member Author

@sisp sisp left a comment

Choose a reason for hiding this comment

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

@yajo I think this PR is ready for review now. There is one uncovered line, please see my inline comment.

try:
type_fn = CAST_STR_TO_NATIVE[type_name]
except KeyError:
raise InvalidTypeError("Invalid answer type")
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how to cover this error by a test as it doesn't occur in practice because the question type is checked to be one of the keys of CAST_STR_TO_NATIVE before. Nevertheless, this function could theoretically be called in a different context, so I think it makes sense to keep the check here.

@yajo
Copy link
Member

yajo commented Apr 19, 2023

Could you please solve the conflicts?

@sisp
Copy link
Member Author

sisp commented Apr 19, 2023

Done.

@yajo yajo merged commit ed38f24 into copier-org:master Apr 23, 2023
@sisp sisp deleted the feat/validate-default-values branch April 23, 2023 05:46
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.

2 participants