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

Function test_reverse_mount_urls

tests/test_routing.py:386–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

384
385
386def test_reverse_mount_urls() -> None:
387 mounted = Router([Mount("/users", ok, name="users")])
388 assert mounted.url_path_for("users", path="/a") == "/users/a"
389
390 users = Router([Route("/{username}", ok, name="user")])
391 mounted = Router([Mount("/{subpath}/users", users, name="users")])
392 assert mounted.url_path_for("users:user", subpath="test", username="tom") == "/test/users/tom"
393 assert mounted.url_path_for("users", subpath="test", path="/tom") == "/test/users/tom"
394
395 mounted = Router([Mount("/users", ok, name="users")])
396 with pytest.raises(NoMatchFound):
397 mounted.url_path_for("users", path="/a", foo="bar")
398
399 mounted = Router([Mount("/users", ok, name="users")])
400 with pytest.raises(NoMatchFound):
401 mounted.url_path_for("users")
402
403
404def test_mount_at_root(test_client_factory: TestClientFactory) -> None:

Callers

nothing calls this directly

Calls 4

url_path_forMethod · 0.95
RouterClass · 0.90
MountClass · 0.90
RouteClass · 0.90

Tested by

no test coverage detected