From 934d0ab7be6929ed5bfa754b591207765b76d607 Mon Sep 17 00:00:00 2001 From: Mridankan Mandal Date: Wed, 22 Jul 2026 17:17:00 +0530 Subject: [PATCH 1/2] Add ResponseTypes.from_args precedence tests Signed-off-by: Mridankan Mandal --- tests/test_responsetypes.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py index 7c9f717e4..d2b8aeceb 100644 --- a/tests/test_responsetypes.py +++ b/tests/test_responsetypes.py @@ -99,7 +99,6 @@ class TestResponseTypes: assert retcls is cls, f"{source} ==> {retcls} != {cls}" def test_from_args(self): - # TODO: add more tests that check precedence between the different arguments mappings: list[tuple[dict[str, Any], type[Response]]] = [ ({"url": "http://www.example.com/data.csv"}, TextResponse), # headers takes precedence over url @@ -119,6 +118,15 @@ class TestResponseTypes: }, Response, ), + ( + {"headers": Headers(), "url": "http://example.com/data.json"}, + JsonResponse, + ), + ( + {"url": "http://example.com/data.json", "filename": "index.html"}, + JsonResponse, + ), + ({"filename": "data.xml", "body": b""}, XmlResponse), ] for source, cls in mappings: retcls = responsetypes.from_args(**source) From 24f5b30a56bd3917e9b1807e5232ddf31790c608 Mon Sep 17 00:00:00 2001 From: Mridankan Mandal Date: Wed, 22 Jul 2026 17:29:09 +0530 Subject: [PATCH 2/2] Cover ResponseTypes.from_args fallbacks Signed-off-by: Mridankan Mandal --- tests/test_responsetypes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_responsetypes.py b/tests/test_responsetypes.py index d2b8aeceb..5f2f3bdfb 100644 --- a/tests/test_responsetypes.py +++ b/tests/test_responsetypes.py @@ -126,7 +126,12 @@ class TestResponseTypes: {"url": "http://example.com/data.json", "filename": "index.html"}, JsonResponse, ), + ( + {"url": "http://example.com/data.unknown", "filename": "index.html"}, + HtmlResponse, + ), ({"filename": "data.xml", "body": b""}, XmlResponse), + ({"filename": "data.unknown", "body": b""}, HtmlResponse), ] for source, cls in mappings: retcls = responsetypes.from_args(**source)