]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:white_check_mark: Test for missing required body
authorSebastián Ramírez <tiangolo@gmail.com>
Tue, 18 Dec 2018 18:57:09 +0000 (22:57 +0400)
committerSebastián Ramírez <tiangolo@gmail.com>
Tue, 18 Dec 2018 18:57:09 +0000 (22:57 +0400)
tests/test_tutorial/test_body/test_tutorial001.py

index f665eb0ba4f00a44cd7dd9de8210de901c973c39..7a07c0367c943a18c30d276de0fc2678fc1c6c33 100644 (file)
@@ -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):