-
Notifications
You must be signed in to change notification settings - Fork 13
feat: handle request.GET or request.POST being None + a few other improvements @W-18128971 #173
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
Conversation
field = machinery.field(type=str) | ||
actual = field.get_without_default(None, request) | ||
self.assertIsNone(actual) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could maybe add a test with request
with query_dict
but without name
or api_name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would fail in a different way because the there's a meta class that has to fill in that name and in the tests it would need to be mocked
int_field.get_without_default(None, request) | ||
|
||
self.assertIn( | ||
f"Could not parse {antagonistical_value} as type int", str(cm.exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could also check for the presence of new log ev=dda, loc=coerce_value_to_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much benefit from asserting the log line is there, also makes the logging updates difficult after (tests would need update too)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
field = machinery.field(type=str) | ||
actual = field.get_without_default(None, request) | ||
self.assertIsNone(actual) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would fail in a different way because the there's a meta class that has to fill in that name and in the tests it would need to be mocked
int_field.get_without_default(None, request) | ||
|
||
self.assertIn( | ||
f"Could not parse {antagonistical_value} as type int", str(cm.exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much benefit from asserting the log line is there, also makes the logging updates difficult after (tests would need update too)
Work Item: W-18078839
RequstField.get_without_default
methodpyproject.toml
pip install
succeeds with a clean virtualenv