test_starlette_urlconvertors.py — fastapi Source File
Architecture documentation for test_starlette_urlconvertors.py, a python file in the fastapi codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3d9afe81_82a8_d495_9d65_561bed476c46["test_starlette_urlconvertors.py"] 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 3d9afe81_82a8_d495_9d65_561bed476c46 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 3d9afe81_82a8_d495_9d65_561bed476c46 --> a7c04dee_ee23_5891_b185_47ff6bed036d style 3d9afe81_82a8_d495_9d65_561bed476c46 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from fastapi import FastAPI, Path, Query
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/int/{param:int}")
def int_convertor(param: int = Path()):
return {"int": param}
@app.get("/float/{param:float}")
def float_convertor(param: float = Path()):
return {"float": param}
@app.get("/path/{param:path}")
def path_convertor(param: str = Path()):
return {"path": param}
@app.get("/query/")
def query_convertor(param: str = Query()):
return {"query": param}
client = TestClient(app)
def test_route_converters_int():
# Test integer conversion
response = client.get("/int/5")
assert response.status_code == 200, response.text
assert response.json() == {"int": 5}
assert app.url_path_for("int_convertor", param=5) == "/int/5" # type: ignore
def test_route_converters_float():
# Test float conversion
response = client.get("/float/25.5")
assert response.status_code == 200, response.text
assert response.json() == {"float": 25.5}
assert app.url_path_for("float_convertor", param=25.5) == "/float/25.5" # type: ignore
def test_route_converters_path():
# Test path conversion
response = client.get("/path/some/example")
assert response.status_code == 200, response.text
assert response.json() == {"path": "some/example"}
def test_route_converters_query():
# Test query conversion
response = client.get("/query", params={"param": "Qué tal!"})
assert response.status_code == 200, response.text
assert response.json() == {"query": "Qué tal!"}
def test_url_path_for_path_convertor():
assert (
app.url_path_for("path_convertor", param="some/example") == "/path/some/example"
)
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does test_starlette_urlconvertors.py do?
test_starlette_urlconvertors.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_starlette_urlconvertors.py?
test_starlette_urlconvertors.py defines 9 function(s): float_convertor, int_convertor, path_convertor, query_convertor, test_route_converters_float, test_route_converters_int, test_route_converters_path, test_route_converters_query, test_url_path_for_path_convertor.
What does test_starlette_urlconvertors.py depend on?
test_starlette_urlconvertors.py imports 2 module(s): __init__.py, testclient.py.
Where is test_starlette_urlconvertors.py in the architecture?
test_starlette_urlconvertors.py is located at tests/test_starlette_urlconvertors.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