Home / File/ test_sub_callbacks.py — fastapi Source File

test_sub_callbacks.py — fastapi Source File

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

File python FastAPI Applications 5 imports 5 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2["test_sub_callbacks.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2 --> 0dda2280_3359_8460_301c_e98c77e78185
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  c7ec4853_513f_84fd_a1ef_04f2932e2fd2 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style c7ec4853_513f_84fd_a1ef_04f2932e2fd2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Optional

from fastapi import APIRouter, FastAPI
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel, HttpUrl

app = FastAPI()


class Invoice(BaseModel):
    id: str
    title: Optional[str] = None
    customer: str
    total: float


class InvoiceEvent(BaseModel):
    description: str
    paid: bool


class InvoiceEventReceived(BaseModel):
    ok: bool


invoices_callback_router = APIRouter()


@invoices_callback_router.post(
    "{$callback_url}/invoices/{$request.body.id}", response_model=InvoiceEventReceived
)
def invoice_notification(body: InvoiceEvent):
    pass  # pragma: nocover


class Event(BaseModel):
    name: str
    total: float


events_callback_router = APIRouter()


@events_callback_router.get("{$callback_url}/events/{$request.body.title}")
def event_callback(event: Event):
    pass  # pragma: nocover


subrouter = APIRouter()


@subrouter.post("/invoices/", callbacks=invoices_callback_router.routes)
def create_invoice(invoice: Invoice, callback_url: Optional[HttpUrl] = None):
    """
    Create an invoice.

    This will (let's imagine) let the API user (some external developer) create an
    invoice.

// ... (249 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_sub_callbacks.py do?
test_sub_callbacks.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_sub_callbacks.py?
test_sub_callbacks.py defines 5 function(s): create_invoice, event_callback, invoice_notification, test_get, test_openapi_schema.
What does test_sub_callbacks.py depend on?
test_sub_callbacks.py imports 5 module(s): __init__.py, inline_snapshot, pydantic, testclient.py, typing.
Where is test_sub_callbacks.py in the architecture?
test_sub_callbacks.py is located at tests/test_sub_callbacks.py (domain: FastAPI, subdomain: Applications, directory: tests).

Analyze Your Own Codebase

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

Try Supermodel Free