test_json_type.py — fastapi Source File
Architecture documentation for test_json_type.py, a python file in the fastapi codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 029f405e_0e07_426c_a94c_205687479803["test_json_type.py"] c1ef60e8_e635_2e82_29e5_a79e03e975d6["json"] 029f405e_0e07_426c_a94c_205687479803 --> c1ef60e8_e635_2e82_29e5_a79e03e975d6 0dda2280_3359_8460_301c_e98c77e78185["typing"] 029f405e_0e07_426c_a94c_205687479803 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 029f405e_0e07_426c_a94c_205687479803 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 029f405e_0e07_426c_a94c_205687479803 --> a7c04dee_ee23_5891_b185_47ff6bed036d 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] 029f405e_0e07_426c_a94c_205687479803 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style 029f405e_0e07_426c_a94c_205687479803 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import json
from typing import Annotated
from fastapi import Cookie, FastAPI, Form, Header, Query
from fastapi.testclient import TestClient
from pydantic import Json
app = FastAPI()
@app.post("/form-json-list")
def form_json_list(items: Annotated[Json[list[str]], Form()]) -> list[str]:
return items
@app.get("/query-json-list")
def query_json_list(items: Annotated[Json[list[str]], Query()]) -> list[str]:
return items
@app.get("/header-json-list")
def header_json_list(x_items: Annotated[Json[list[str]], Header()]) -> list[str]:
return x_items
@app.get("/cookie-json-list")
def cookie_json_list(items: Annotated[Json[list[str]], Cookie()]) -> list[str]:
return items
client = TestClient(app)
def test_form_json_list():
response = client.post(
"/form-json-list", data={"items": json.dumps(["abc", "def"])}
)
assert response.status_code == 200, response.text
assert response.json() == ["abc", "def"]
def test_query_json_list():
response = client.get(
"/query-json-list", params={"items": json.dumps(["abc", "def"])}
)
assert response.status_code == 200, response.text
assert response.json() == ["abc", "def"]
def test_header_json_list():
response = client.get(
"/header-json-list", headers={"x-items": json.dumps(["abc", "def"])}
)
assert response.status_code == 200, response.text
assert response.json() == ["abc", "def"]
def test_cookie_json_list():
client.cookies.set("items", json.dumps(["abc", "def"]))
response = client.get("/cookie-json-list")
assert response.status_code == 200, response.text
assert response.json() == ["abc", "def"]
client.cookies.clear()
Domain
Subdomains
Functions
Dependencies
- __init__.py
- json
- pydantic
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_json_type.py do?
test_json_type.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_json_type.py?
test_json_type.py defines 8 function(s): cookie_json_list, form_json_list, header_json_list, query_json_list, test_cookie_json_list, test_form_json_list, test_header_json_list, test_query_json_list.
What does test_json_type.py depend on?
test_json_type.py imports 5 module(s): __init__.py, json, pydantic, testclient.py, typing.
Where is test_json_type.py in the architecture?
test_json_type.py is located at tests/test_json_type.py (domain: FastAPI, subdomain: Responses, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free