Home / File/ test_tutorial006.py — fastapi Source File

test_tutorial006.py — fastapi Source File

Architecture documentation for test_tutorial006.py, a python file in the fastapi codebase. 4 imports, 0 dependents.

File python FastAPI Responses 4 imports 6 functions

Entity Profile

Dependency Diagram

graph LR
  b19de0a0_bef6_3909_8069_0662d6b557b6["test_tutorial006.py"]
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  b19de0a0_bef6_3909_8069_0662d6b557b6 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  b19de0a0_bef6_3909_8069_0662d6b557b6 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  b19de0a0_bef6_3909_8069_0662d6b557b6 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  b19de0a0_bef6_3909_8069_0662d6b557b6 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style b19de0a0_bef6_3909_8069_0662d6b557b6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib

import pytest
from fastapi.testclient import TestClient
from inline_snapshot import snapshot


@pytest.fixture(
    name="client",
    params=[
        pytest.param("tutorial006_py39"),
        pytest.param("tutorial006_an_py39"),
    ],
)
def get_client(request: pytest.FixtureRequest):
    mod = importlib.import_module(f"docs_src.dependencies.{request.param}")

    client = TestClient(mod.app)
    return client


def test_get_no_headers(client: TestClient):
    response = client.get("/items/")
    assert response.status_code == 422, response.text
    assert response.json() == {
        "detail": [
            {
                "type": "missing",
                "loc": ["header", "x-token"],
                "msg": "Field required",
                "input": None,
            },
            {
                "type": "missing",
                "loc": ["header", "x-key"],
                "msg": "Field required",
                "input": None,
            },
        ]
    }


def test_get_invalid_one_header(client: TestClient):
    response = client.get("/items/", headers={"X-Token": "invalid"})
    assert response.status_code == 400, response.text
    assert response.json() == {"detail": "X-Token header invalid"}


def test_get_invalid_second_header(client: TestClient):
    response = client.get(
        "/items/", headers={"X-Token": "fake-super-secret-token", "X-Key": "invalid"}
    )
    assert response.status_code == 400, response.text
    assert response.json() == {"detail": "X-Key header invalid"}


def test_get_valid_headers(client: TestClient):
    response = client.get(
        "/items/",
        headers={
// ... (91 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_tutorial006.py do?
test_tutorial006.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_tutorial006.py?
test_tutorial006.py defines 6 function(s): get_client, test_get_invalid_one_header, test_get_invalid_second_header, test_get_no_headers, test_get_valid_headers, test_openapi_schema.
What does test_tutorial006.py depend on?
test_tutorial006.py imports 4 module(s): importlib, inline_snapshot, pytest, testclient.py.
Where is test_tutorial006.py in the architecture?
test_tutorial006.py is located at tests/test_tutorial/test_dependencies/test_tutorial006.py (domain: FastAPI, subdomain: Responses, directory: tests/test_tutorial/test_dependencies).

Analyze Your Own Codebase

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

Try Supermodel Free