(client: TestClient)
| 224 | |
| 225 | |
| 226 | def test_route_converters(client: TestClient) -> None: |
| 227 | # Test integer conversion |
| 228 | response = client.get("/int/5") |
| 229 | assert response.status_code == 200 |
| 230 | assert response.json() == {"int": 5} |
| 231 | assert app.url_path_for("int-convertor", param=5) == "/int/5" |
| 232 | |
| 233 | # Test path with parentheses |
| 234 | response = client.get("/path-with-parentheses(7)") |
| 235 | assert response.status_code == 200 |
| 236 | assert response.json() == {"int": 7} |
| 237 | assert app.url_path_for("path-with-parentheses", param=7) == "/path-with-parentheses(7)" |
| 238 | |
| 239 | # Test float conversion |
| 240 | response = client.get("/float/25.5") |
| 241 | assert response.status_code == 200 |
| 242 | assert response.json() == {"float": 25.5} |
| 243 | assert app.url_path_for("float-convertor", param=25.5) == "/float/25.5" |
| 244 | |
| 245 | # Test path conversion |
| 246 | response = client.get("/path/some/example") |
| 247 | assert response.status_code == 200 |
| 248 | assert response.json() == {"path": "some/example"} |
| 249 | assert app.url_path_for("path-convertor", param="some/example") == "/path/some/example" |
| 250 | |
| 251 | # Test UUID conversion |
| 252 | response = client.get("/uuid/ec38df32-ceda-4cfa-9b4a-1aeb94ad551a") |
| 253 | assert response.status_code == 200 |
| 254 | assert response.json() == {"uuid": "ec38df32-ceda-4cfa-9b4a-1aeb94ad551a"} |
| 255 | assert ( |
| 256 | app.url_path_for("uuid-convertor", param=uuid.UUID("ec38df32-ceda-4cfa-9b4a-1aeb94ad551a")) |
| 257 | == "/uuid/ec38df32-ceda-4cfa-9b4a-1aeb94ad551a" |
| 258 | ) |
| 259 | |
| 260 | |
| 261 | def test_url_path_for() -> None: |
nothing calls this directly
no test coverage detected