From: Sebastián Ramírez Date: Tue, 18 Dec 2018 18:57:09 +0000 (+0400) Subject: :white_check_mark: Test for missing required body X-Git-Tag: 0.1.12~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=22dc7e913268c0b15cc76d69e57bca174d440ca7;p=thirdparty%2Ffastapi%2Ffastapi.git :white_check_mark: Test for missing required body --- diff --git a/tests/test_tutorial/test_body/test_tutorial001.py b/tests/test_tutorial/test_body/test_tutorial001.py index f665eb0ba4..7a07c0367c 100644 --- a/tests/test_tutorial/test_body/test_tutorial001.py +++ b/tests/test_tutorial/test_body/test_tutorial001.py @@ -124,6 +124,16 @@ name_price_missing = { ] } +body_missing = { + "detail": [ + { + "loc": ["body", "item"], + "msg": "field required", + "type": "value_error.missing", + } + ] +} + @pytest.mark.parametrize( "path,body,expected_status,expected_response", @@ -155,6 +165,7 @@ name_price_missing = { ("/items/", {"name": "Foo"}, 422, price_missing), ("/items/", {"name": "Foo", "price": "twenty"}, 422, price_not_float), ("/items/", {}, 422, name_price_missing), + ("/items/", None, 422, body_missing), ], ) def test_post_body(path, body, expected_status, expected_response):