forked from marshmallow-code/webargs
/
test_falconparser.py
40 lines (32 loc) · 1.3 KB
/
test_falconparser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import pytest
from webargs.testing import CommonTestCase
from tests.apps.falcon_app import create_app
class TestFalconParser(CommonTestCase):
def create_app(self):
return create_app()
@pytest.mark.skip(reason="files location not supported for falconparser")
def test_parse_files(self, testapp):
pass
def test_use_args_hook(self, testapp):
assert testapp.get("/echo_use_args_hook?name=Fred").json == {"name": "Fred"}
# https://github.com/marshmallow-code/webargs/issues/427
def test_parse_json_with_nonutf8_chars(self, testapp):
res = testapp.post(
"/echo",
b"\xfe",
headers={"Accept": "application/json", "Content-Type": "application/json"},
expect_errors=True,
)
assert res.status_code == 400
assert res.json["errors"] == {"json": ["Invalid JSON body."]}
# https://github.com/sloria/webargs/issues/329
def test_invalid_json(self, testapp):
res = testapp.post(
"/echo",
'{"foo": "bar", }',
headers={"Accept": "application/json", "Content-Type": "application/json"},
expect_errors=True,
)
assert res.status_code == 400
assert res.json["errors"] == {"json": ["Invalid JSON body."]}