-
Notifications
You must be signed in to change notification settings - Fork 149
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
Add colander_body_validator (fixes #386) #395
Conversation
|
||
def test_invalid_json(self): | ||
app = self.make_ordinary_app() | ||
response = app.post('/foobar?yeah=test', | ||
response = app.post('/signup', | ||
"invalid json input", |
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.
test_invalid_json
and test_json_text
looks like the same test to me. Can we put real wrong json here?
'{"foo": "bar"'
for instance
@@ -155,13 +155,23 @@ def post7(request): | |||
null | |||
) | |||
|
|||
from cornice.validators import colander_validator | |||
from cornice.validators import colander_validator, colander_body_validator | |||
|
|||
COLANDER = True | |||
except ImportError: | |||
COLANDER = False | |||
|
|||
if COLANDER: |
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 would gladly use skipIf
instead here
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.
<msg mode="getshitdone">
Please do it in another PR, this is out of scope here </msg>
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.
Yes
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.
Actually I was wrong, we are defining stuff there that needs colander to be defined.
Please ignore my comment.
from cornice.validators._colander import validator as colander_validator # noqa | ||
from cornice.validators._colander import ( | ||
validator as colander_validator, | ||
body_validator as colander_body_validator) # flake8: noqa |
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.
Why do we need a # noqa
here?
I think the syntax # flake8: noqa
is when you want to remote the file from flake8, # NOQA
should be sufficient here.
body_validator as colander_body_validator) | ||
|
||
|
||
__all__ = ['colander_validator', 'colander_body_validator', 'extract_cstruct'] |
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 probably want to add DEFAULT_VALIDATORS
and DEFAULT_FILTERS
too.
@Natim r?