feat: handle request.GET or request.POST being None + a few other improvements @W-18128971#173
feat: handle request.GET or request.POST being None + a few other improvements @W-18128971#173
Conversation
| field = machinery.field(type=str) | ||
| actual = field.get_without_default(None, request) | ||
| self.assertIsNone(actual) | ||
|
|
There was a problem hiding this comment.
we could maybe add a test with request with query_dict but without name or api_name
There was a problem hiding this comment.
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.
we could also check for the presence of new log ev=dda, loc=coerce_value_to_type
There was a problem hiding this comment.
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)
| field = machinery.field(type=str) | ||
| actual = field.get_without_default(None, request) | ||
| self.assertIsNone(actual) | ||
|
|
There was a problem hiding this comment.
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.
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_defaultmethodpyproject.tomlpip installsucceeds with a clean virtualenv