Skip to content

Commit 290024a

Browse files
add more coverage
1 parent 4e504ce commit 290024a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/functional/event_handler/required_dependencies/test_http_resolver.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,3 +1215,30 @@ async def raise_error():
12151215
# THEN it propagates up
12161216
with pytest.raises(ValueError, match="Async unhandled error"):
12171217
await app(scope, receive, send)
1218+
1219+
1220+
@pytest.mark.asyncio
1221+
async def test_asgi_wrong_method_returns_not_found():
1222+
# GIVEN an app with only a GET route
1223+
app = HttpResolverLocal()
1224+
1225+
@app.get("/hello")
1226+
def hello():
1227+
return {"message": "Hello"}
1228+
1229+
# WHEN calling with POST method (route exists but method doesn't match)
1230+
scope = {
1231+
"type": "http",
1232+
"method": "POST",
1233+
"path": "/hello",
1234+
"query_string": b"",
1235+
"headers": [],
1236+
}
1237+
1238+
receive = make_asgi_receive()
1239+
send, captured = make_asgi_send()
1240+
1241+
await app(scope, receive, send)
1242+
1243+
# THEN it returns 404 (method mismatch is treated as not found)
1244+
assert captured["status_code"] == 404

0 commit comments

Comments
 (0)