Home / File/ test_tutorial001.py — fastapi Source File

test_tutorial001.py — fastapi Source File

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

File python FastAPI Routing 6 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  fc1a2c7b_8d93_9b92_34cb_c5b381629791["test_tutorial001.py"]
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  8fd7072e_05b0_6622_0f14_e1e357032855["utils.py"]
  fc1a2c7b_8d93_9b92_34cb_c5b381629791 --> 8fd7072e_05b0_6622_0f14_e1e357032855
  style fc1a2c7b_8d93_9b92_34cb_c5b381629791 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib
from types import ModuleType

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

from tests.utils import needs_py310


@pytest.fixture(
    name="mod",
    params=[
        pytest.param("tutorial001_py39"),
        pytest.param("tutorial001_py310", marks=needs_py310),
    ],
)
def get_mod(request: pytest.FixtureRequest):
    mod = importlib.import_module(f"docs_src.openapi_callbacks.{request.param}")
    return mod


@pytest.fixture(name="client")
def get_client(mod: ModuleType):
    client = TestClient(mod.app)
    client.headers.clear()
    return client


def test_get(client: TestClient):
    response = client.post(
        "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    )
    assert response.status_code == 200, response.text
    assert response.json() == {"msg": "Invoice received"}


def test_dummy_callback(mod: ModuleType):
    # Just for coverage
    mod.invoice_notification({})


def test_openapi_schema(client: TestClient):
    response = client.get("/openapi.json")
    assert response.status_code == 200, response.text
    assert response.json() == snapshot(
        {
            "openapi": "3.1.0",
            "info": {"title": "FastAPI", "version": "0.1.0"},
            "paths": {
                "/invoices/": {
                    "post": {
                        "summary": "Create Invoice",
                        "description": 'Create an invoice.\n\nThis will (let\'s imagine) let the API user (some external developer) create an\ninvoice.\n\nAnd this path operation will:\n\n* Send the invoice to the client.\n* Collect the money from the client.\n* Send a notification back to the API user (the external developer), as a callback.\n    * At this point is that the API will somehow send a POST request to the\n        external API with the notification of the invoice event\n        (e.g. "payment successful").',
                        "operationId": "create_invoice_invoices__post",
                        "parameters": [
                            {
                                "required": False,
                                "schema": {
                                    "anyOf": [
// ... (150 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_tutorial001.py do?
test_tutorial001.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in test_tutorial001.py?
test_tutorial001.py defines 5 function(s): get_client, get_mod, test_dummy_callback, test_get, test_openapi_schema.
What does test_tutorial001.py depend on?
test_tutorial001.py imports 6 module(s): importlib, inline_snapshot, pytest, testclient.py, types, utils.py.
Where is test_tutorial001.py in the architecture?
test_tutorial001.py is located at tests/test_tutorial/test_openapi_callbacks/test_tutorial001.py (domain: FastAPI, subdomain: Routing, directory: tests/test_tutorial/test_openapi_callbacks).

Analyze Your Own Codebase

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

Try Supermodel Free