MCPcopy
hub / github.com/encode/starlette / test_url_for

Function test_url_for

tests/test_routing.py:275–292  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

273
274
275def test_url_for() -> None:
276 assert app.url_path_for("homepage").make_absolute_url(base_url="https://example.org") == "https://example.org/"
277 assert (
278 app.url_path_for("homepage").make_absolute_url(base_url="https://example.org/root_path/")
279 == "https://example.org/root_path/"
280 )
281 assert (
282 app.url_path_for("user", username="tomchristie").make_absolute_url(base_url="https://example.org")
283 == "https://example.org/users/tomchristie"
284 )
285 assert (
286 app.url_path_for("user", username="tomchristie").make_absolute_url(base_url="https://example.org/root_path/")
287 == "https://example.org/root_path/users/tomchristie"
288 )
289 assert (
290 app.url_path_for("websocket_endpoint").make_absolute_url(base_url="https://example.org")
291 == "wss://example.org/ws"
292 )
293
294
295def test_router_add_route(client: TestClient) -> None:

Callers

nothing calls this directly

Calls 2

make_absolute_urlMethod · 0.80
url_path_forMethod · 0.45

Tested by

no test coverage detected