Skip to content

Commit

Permalink
✅ Add tests to check that by default request bodies are assumed as JS…
Browse files Browse the repository at this point in the history
…ON when no content-type header is provided
  • Loading branch information
tiangolo committed Jul 3, 2021
1 parent 0d73aaf commit 540f19f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_tutorial/test_body/test_tutorial001.py
Expand Up @@ -229,6 +229,20 @@ def test_geo_json():
assert response.status_code == 200, response.text


def test_no_content_type_is_json():
response = client.post(
"/items/",
data='{"name": "Foo", "price": 50.5}',
)
assert response.status_code == 200, response.text
assert response.json() == {
"name": "Foo",
"description": None,
"price": 50.5,
"tax": None,
}


def test_wrong_headers():
data = '{"name": "Foo", "price": 50.5}'
invalid_dict = {
Expand Down

0 comments on commit 540f19f

Please sign in to comment.