Home / Function/ test_wrong_headers() — fastapi Function Reference

test_wrong_headers() — fastapi Function Reference

Architecture documentation for the test_wrong_headers() function in test_tutorial001.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  ca57db98_3bfc_42a0_eb74_3379ff0e1aa7["test_wrong_headers()"]
  384ebf37_bf33_dd11_7410_101f39082f41["test_tutorial001.py"]
  ca57db98_3bfc_42a0_eb74_3379ff0e1aa7 -->|defined in| 384ebf37_bf33_dd11_7410_101f39082f41
  style ca57db98_3bfc_42a0_eb74_3379ff0e1aa7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_tutorial/test_body/test_tutorial001.py lines 207–252

def test_wrong_headers(client: TestClient):
    data = '{"name": "Foo", "price": 50.5}'
    response = client.post(
        "/items/", content=data, headers={"Content-Type": "text/plain"}
    )
    assert response.status_code == 422, response.text
    assert response.json() == {
        "detail": [
            {
                "type": "model_attributes_type",
                "loc": ["body"],
                "msg": "Input should be a valid dictionary or object to extract fields from",
                "input": '{"name": "Foo", "price": 50.5}',
            }
        ]
    }

    response = client.post(
        "/items/", content=data, headers={"Content-Type": "application/geo+json-seq"}
    )
    assert response.status_code == 422, response.text
    assert response.json() == {
        "detail": [
            {
                "type": "model_attributes_type",
                "loc": ["body"],
                "msg": "Input should be a valid dictionary or object to extract fields from",
                "input": '{"name": "Foo", "price": 50.5}',
            }
        ]
    }

    response = client.post(
        "/items/", content=data, headers={"Content-Type": "application/not-really-json"}
    )
    assert response.status_code == 422, response.text
    assert response.json() == {
        "detail": [
            {
                "type": "model_attributes_type",
                "loc": ["body"],
                "msg": "Input should be a valid dictionary or object to extract fields from",
                "input": '{"name": "Foo", "price": 50.5}',
            }
        ]
    }

Domain

Subdomains

Frequently Asked Questions

What does test_wrong_headers() do?
test_wrong_headers() is a function in the fastapi codebase, defined in tests/test_tutorial/test_body/test_tutorial001.py.
Where is test_wrong_headers() defined?
test_wrong_headers() is defined in tests/test_tutorial/test_body/test_tutorial001.py at line 207.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free