Test for missing required body

This commit is contained in:
Sebastián Ramírez 2018-12-18 22:57:09 +04:00
parent 7ee32ea197
commit 22dc7e9132
1 changed files with 11 additions and 0 deletions

View 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):