"Topic :: Internet :: WWW/HTTP",
]
dependencies = [
- "starlette==0.21.0",
+ "starlette==0.22.0",
"pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0",
]
dynamic = ["version"]
-from fastapi import FastAPI, Path
+from fastapi import FastAPI, Path, Query
from fastapi.testclient import TestClient
app = FastAPI()
return {"path": param}
+@app.get("/query/")
+def query_convertor(param: str = Query()):
+ return {"query": param}
+
+
client = TestClient(app)
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"