This commit is contained in:
Mridankan Mandal 2026-08-15 11:16:48 -05:00 committed by GitHub
commit a02dc729e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 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,20 @@ class TestResponseTypes:
},
Response,
),
(
{"headers": Headers(), "url": "http://example.com/data.json"},
JsonResponse,
),
(
{"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"<html></html>"}, XmlResponse),
({"filename": "data.unknown", "body": b"<html></html>"}, HtmlResponse),
]
for source, cls in mappings:
retcls = responsetypes.from_args(**source)