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

Add colander_body_validator (fixes #386) #395

Merged
merged 5 commits into from
Oct 20, 2016

Conversation

leplatrem
Copy link
Contributor

@Natim r?


def test_invalid_json(self):
app = self.make_ordinary_app()
response = app.post('/foobar?yeah=test',
response = app.post('/signup',
"invalid json input",
Copy link
Contributor

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:
Copy link
Contributor

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

Copy link
Contributor Author

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>

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes

Copy link
Contributor

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
Copy link
Contributor

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']
Copy link
Contributor

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.

@leplatrem leplatrem merged commit 01cea7d into master Oct 20, 2016
@leplatrem leplatrem deleted the 386-colander-body-validator branch October 20, 2016 10:16
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