Home / File/ test_extra_routes.py — fastapi Source File

test_extra_routes.py — fastapi Source File

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

File python FastAPI Applications 6 imports 15 functions 1 classes

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

from typing import Optional

from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    price: Optional[float] = None


@app.api_route("/items/{item_id}", methods=["GET"])
def get_items(item_id: str):
    return {"item_id": item_id}


def get_not_decorated(item_id: str):
    return {"item_id": item_id}


app.add_api_route("/items-not-decorated/{item_id}", get_not_decorated)


@app.delete("/items/{item_id}")
def delete_item(item_id: str, item: Item):
    return {"item_id": item_id, "item": item}


@app.head("/items/{item_id}")
def head_item(item_id: str):
    return JSONResponse(None, headers={"x-fastapi-item-id": item_id})


@app.options("/items/{item_id}")
def options_item(item_id: str):
    return JSONResponse(None, headers={"x-fastapi-item-id": item_id})


@app.patch("/items/{item_id}")
def patch_item(item_id: str, item: Item):
    return {"item_id": item_id, "item": item}


@app.trace("/items/{item_id}")
def trace_item(item_id: str):
    return JSONResponse(None, media_type="message/http")


client = TestClient(app)


def test_get_api_route():
    response = client.get("/items/foo")
    assert response.status_code == 200, response.text
    assert response.json() == {"item_id": "foo"}
// ... (313 more lines)

Domain

Subdomains

Classes

Dependencies

Frequently Asked Questions

What does test_extra_routes.py do?
test_extra_routes.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_extra_routes.py?
test_extra_routes.py defines 15 function(s): delete_item, get_items, get_not_decorated, head_item, options_item, patch_item, test_delete, test_get_api_route, test_get_api_route_not_decorated, test_head, and 5 more.
What does test_extra_routes.py depend on?
test_extra_routes.py imports 6 module(s): __init__.py, inline_snapshot, pydantic, responses.py, testclient.py, typing.
Where is test_extra_routes.py in the architecture?
test_extra_routes.py is located at tests/test_extra_routes.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