diff --git a/tests/test_utils_response.py b/tests/test_utils_response.py index 53366d428..0caa7b051 100644 --- a/tests/test_utils_response.py +++ b/tests/test_utils_response.py @@ -450,6 +450,16 @@ POST_XTRACTMIME_SCENARIOS = ( 'application/ld+json', ) ), + + # XML MIME types should trigger an XmlResponse. + # + # https://mimesniff.spec.whatwg.org/#xml-mime-type + *( + (mime_type, XmlResponse) + for mime_type in ( + 'application/foo+xml', + ) + ), ) ), @@ -500,6 +510,21 @@ POST_XTRACTMIME_SCENARIOS = ( ) ), + # Content-Type also triumphs Content-Disposition. + ( + { + 'headers': Headers( + { + 'Content-Disposition': [ + 'attachment; filename="a.html"', + ], + 'Content-Type': ['application/octet-stream'], + } + ) + }, + Response, + ), + # Compressed content should be of type Response until uncompressed. ( { @@ -514,17 +539,6 @@ POST_XTRACTMIME_SCENARIOS = ( }, Response, ), - ( - { - "url": "file:///a.html", - 'headers': Headers( - { - 'Content-Encoding': ['zip'], - } - ) - }, - Response, - ), ( { "body": b"", @@ -595,6 +609,28 @@ POST_XTRACTMIME_SCENARIOS = ( ) ), + # File extension triumphs body. + ( + { + "body": b"", + 'headers': Headers( + { + 'Content-Disposition': [ + 'attachment; filename="a.gz"', + ], + } + ) + }, + Response, + ), + ( + { + "body": b"", + 'url': 'file:///a.gz', + }, + Response, + ), + # Without anything else, the body determines the response class. *( ({"body": body}, response_class)