Skip to content

Commit

Permalink
Merge pull request #274 from sloria/ma3-tests
Browse files Browse the repository at this point in the history
Fix tests against marshmallow 3.0.0b12
  • Loading branch information
sloria committed Aug 19, 2018
2 parents 63f22be + 7cbcd62 commit 2a3fb34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def test_parse_json_many_schema_invalid_input(self, testapp):
assert res.status_code == 422

def test_parse_json_many_schema(self, testapp):
res = testapp.post_json("/echo_many_schema", [{"extra": "data"}]).json
assert res == [{"name": "World"}]
res = testapp.post_json("/echo_many_schema", [{"name": "Steve"}]).json
assert res == [{"name": "Steve"}]

def test_parse_json_many_schema_ignore_malformed_data(self, testapp):
assert testapp.post_json("/echo_many_schema", {"extra": "data"}).json == []
Expand Down
19 changes: 7 additions & 12 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,15 @@ class Meta:
strict = True

def test_passing_schema_to_parse(self, parser, web_request):
web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

result = parser.parse(self.UserSchema(**strict_kwargs), web_request)

assert result == {"email": "foo@bar.com", "password": "bar"}

def test_use_args_can_be_passed_a_schema(self, web_request, parser):

web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

@parser.use_args(self.UserSchema(**strict_kwargs), web_request)
def viewfunc(args):
Expand All @@ -719,7 +719,7 @@ def viewfunc(args):
assert viewfunc() == {"email": "foo@bar.com", "password": "bar"}

def test_passing_schema_factory_to_parse(self, parser, web_request):
web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

def factory(req):
assert req is web_request
Expand All @@ -730,7 +730,7 @@ def factory(req):
assert result == {"email": "foo@bar.com", "password": "bar"}

def test_use_args_can_be_passed_a_schema_factory(self, web_request, parser):
web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

def factory(req):
assert req is web_request
Expand All @@ -744,7 +744,7 @@ def viewfunc(args):

def test_use_kwargs_can_be_passed_a_schema(self, web_request, parser):

web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

@parser.use_kwargs(self.UserSchema(**strict_kwargs), web_request)
def viewfunc(email, password):
Expand All @@ -753,7 +753,7 @@ def viewfunc(email, password):
assert viewfunc() == {"email": "foo@bar.com", "password": "bar"}

def test_use_kwargs_can_be_passed_a_schema_factory(self, web_request, parser):
web_request.json = {"id": 12, "email": "foo@bar.com", "password": "bar"}
web_request.json = {"email": "foo@bar.com", "password": "bar"}

def factory(req):
assert req is web_request
Expand Down Expand Up @@ -783,12 +783,7 @@ def test_warning_raised_if_schema_is_not_in_strict_mode(self, web_request, parse
assert "strict=True" in str(warning.message)

def test_use_kwargs_stacked(self, web_request, parser):
web_request.json = {
"id": 12,
"email": "foo@bar.com",
"password": "bar",
"page": 42,
}
web_request.json = {"email": "foo@bar.com", "password": "bar", "page": 42}

@parser.use_kwargs({"page": fields.Int()}, web_request)
@parser.use_kwargs(self.UserSchema(**strict_kwargs), web_request)
Expand Down

0 comments on commit 2a3fb34

Please sign in to comment.