Add ResponseTypes.from_args precedence tests

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
This commit is contained in:
Mridankan Mandal 2026-07-22 17:17:00 +05:30
parent 1157b3e235
commit 934d0ab7be
No known key found for this signature in database
GPG Key ID: C24AD565E950FF59
1 changed files with 9 additions and 1 deletions

View File

@ -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"<html></html>"}, XmlResponse),
]
for source, cls in mappings:
retcls = responsetypes.from_args(**source)