File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
tests/functional/event_handler/required_dependencies Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments