test_required_noneable.py — fastapi Source File
Architecture documentation for test_required_noneable.py, a python file in the fastapi codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0a36b755_48b9_8332_f5e3_c86a724a63b7["test_required_noneable.py"] 0dda2280_3359_8460_301c_e98c77e78185["typing"] 0a36b755_48b9_8332_f5e3_c86a724a63b7 --> 0dda2280_3359_8460_301c_e98c77e78185 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 0a36b755_48b9_8332_f5e3_c86a724a63b7 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 0a36b755_48b9_8332_f5e3_c86a724a63b7 --> a7c04dee_ee23_5891_b185_47ff6bed036d style 0a36b755_48b9_8332_f5e3_c86a724a63b7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from typing import Union
from fastapi import Body, FastAPI, Query
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/query")
def read_query(q: Union[str, None]):
return q
@app.get("/explicit-query")
def read_explicit_query(q: Union[str, None] = Query()):
return q
@app.post("/body-embed")
def send_body_embed(b: Union[str, None] = Body(embed=True)):
return b
client = TestClient(app)
def test_required_nonable_query_invalid():
response = client.get("/query")
assert response.status_code == 422
def test_required_noneable_query_value():
response = client.get("/query", params={"q": "foo"})
assert response.status_code == 200
assert response.json() == "foo"
def test_required_nonable_explicit_query_invalid():
response = client.get("/explicit-query")
assert response.status_code == 422
def test_required_nonable_explicit_query_value():
response = client.get("/explicit-query", params={"q": "foo"})
assert response.status_code == 200
assert response.json() == "foo"
def test_required_nonable_body_embed_no_content():
response = client.post("/body-embed")
assert response.status_code == 422
def test_required_nonable_body_embed_invalid():
response = client.post("/body-embed", json={"invalid": "invalid"})
assert response.status_code == 422
def test_required_noneable_body_embed_value():
response = client.post("/body-embed", json={"b": "foo"})
assert response.status_code == 200
assert response.json() == "foo"
Domain
Subdomains
Functions
- read_explicit_query()
- read_query()
- send_body_embed()
- test_required_nonable_body_embed_invalid()
- test_required_nonable_body_embed_no_content()
- test_required_nonable_explicit_query_invalid()
- test_required_nonable_explicit_query_value()
- test_required_nonable_query_invalid()
- test_required_noneable_body_embed_value()
- test_required_noneable_query_value()
Dependencies
- __init__.py
- testclient.py
- typing
Source
Frequently Asked Questions
What does test_required_noneable.py do?
test_required_noneable.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_required_noneable.py?
test_required_noneable.py defines 10 function(s): read_explicit_query, read_query, send_body_embed, test_required_nonable_body_embed_invalid, test_required_nonable_body_embed_no_content, test_required_nonable_explicit_query_invalid, test_required_nonable_explicit_query_value, test_required_nonable_query_invalid, test_required_noneable_body_embed_value, test_required_noneable_query_value.
What does test_required_noneable.py depend on?
test_required_noneable.py imports 3 module(s): __init__.py, testclient.py, typing.
Where is test_required_noneable.py in the architecture?
test_required_noneable.py is located at tests/test_required_noneable.py (domain: FastAPI, subdomain: Routing, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free