]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
test: add tests in `test_routing` (#2676)
authorSean Chen <2367058391@qq.com>
Sat, 30 Nov 2024 09:58:59 +0000 (17:58 +0800)
committerGitHub <noreply@github.com>
Sat, 30 Nov 2024 09:58:59 +0000 (09:58 +0000)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
tests/test_routing.py

index fb2bfeec10732b7b5428f5d7679c36314a50790b..6abdc564c138a5f2591a8755bc094ecf3b546c50 100644 (file)
@@ -390,6 +390,14 @@ def test_reverse_mount_urls() -> None:
     assert mounted.url_path_for("users:user", subpath="test", username="tom") == "/test/users/tom"
     assert mounted.url_path_for("users", subpath="test", path="/tom") == "/test/users/tom"
 
+    mounted = Router([Mount("/users", ok, name="users")])
+    with pytest.raises(NoMatchFound):
+        mounted.url_path_for("users", path="/a", foo="bar")
+
+    mounted = Router([Mount("/users", ok, name="users")])
+    with pytest.raises(NoMatchFound):
+        mounted.url_path_for("users")
+
 
 def test_mount_at_root(test_client_factory: TestClientFactory) -> None:
     mounted = Router([Mount("/", ok, name="users")])
@@ -479,6 +487,8 @@ def test_host_reverse_urls() -> None:
         mixed_hosts_app.url_path_for("port:homepage").make_absolute_url("https://whatever")
         == "https://port.example.org:3600/"
     )
+    with pytest.raises(NoMatchFound):
+        mixed_hosts_app.url_path_for("api", path="whatever", foo="bar")
 
 
 async def subdomain_app(scope: Scope, receive: Receive, send: Send) -> None: