Skip to content

Commit

Permalink
馃И Add test to show issue with non-ascii chars in query params
Browse files Browse the repository at this point in the history
  • Loading branch information
azogue committed Nov 18, 2022
1 parent 4638b2c commit 162b36b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_starlette_urlconvertors.py
@@ -1,4 +1,4 @@
from fastapi import FastAPI, Path
from fastapi import FastAPI, Path, Query
from fastapi.testclient import TestClient

app = FastAPI()
Expand All @@ -19,6 +19,11 @@ def path_convertor(param: str = Path()):
return {"path": param}


@app.get("/query/")
def query_convertor(param: str = Query()):
return {"query": param}


client = TestClient(app)


Expand All @@ -45,6 +50,13 @@ def test_route_converters_path():
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"
Expand Down

0 comments on commit 162b36b

Please sign in to comment.