summaryrefslogtreecommitdiff
path: root/tests/responses
diff options
context:
space:
mode:
authorShingenPizza <19253513+ShingenPizza@users.noreply.github.com>2019-05-17 12:07:27 +0200
committerCarlton Gibson <carlton.gibson@noumenal.es>2019-05-17 12:07:27 +0200
commitde4832c49b8a8cf00b2d602ab4d10c4ca69627bd (patch)
tree241c7e3a07366d29b73301db9db06d42ce407ab9 /tests/responses
parent5c19274643dacc0a16e26634aa5dc34bd11a7077 (diff)
downloaddjango-de4832c49b8a8cf00b2d602ab4d10c4ca69627bd.tar.gz
Fixed #30196 -- Made FileResponse set Content-Disposition inline if filename is available.
Diffstat (limited to 'tests/responses')
-rw-r--r--tests/responses/test_fileresponse.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/responses/test_fileresponse.py b/tests/responses/test_fileresponse.py
index 5896373d4d..e77df4513a 100644
--- a/tests/responses/test_fileresponse.py
+++ b/tests/responses/test_fileresponse.py
@@ -14,12 +14,21 @@ class FileResponseTests(SimpleTestCase):
response = FileResponse(open(__file__, 'rb'))
self.assertEqual(response['Content-Length'], str(os.path.getsize(__file__)))
self.assertIn(response['Content-Type'], ['text/x-python', 'text/plain'])
+ self.assertEqual(response['Content-Disposition'], 'inline; filename="test_fileresponse.py"')
response.close()
def test_file_from_buffer_response(self):
response = FileResponse(io.BytesIO(b'binary content'))
self.assertEqual(response['Content-Length'], '14')
self.assertEqual(response['Content-Type'], 'application/octet-stream')
+ self.assertFalse(response.has_header('Content-Disposition'))
+ self.assertEqual(list(response), [b'binary content'])
+
+ def test_file_from_buffer_unnamed_attachment(self):
+ response = FileResponse(io.BytesIO(b'binary content'), as_attachment=True)
+ self.assertEqual(response['Content-Length'], '14')
+ self.assertEqual(response['Content-Type'], 'application/octet-stream')
+ self.assertEqual(response['Content-Disposition'], 'attachment')
self.assertEqual(list(response), [b'binary content'])
@skipIf(sys.platform == 'win32', "Named pipes are Unix-only.")