Skip to content

Commit

Permalink
Added a test for properly auto-determining mime types and setting con…
Browse files Browse the repository at this point in the history
…tent encoding header
  • Loading branch information
Lukáš Kremla committed Aug 13, 2024
1 parent 81caeb0 commit 58dd6c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/files/test.txt.gz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
10 changes: 10 additions & 0 deletions tests/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ def test_send_file_compressed(self):
'application/octet-stream')
self.assertEqual(res.headers['Content-Encoding'], 'gzip')

def test_send_file_with_correct_mime_type_and_content_encoding(self):
res = Response.send_file('tests/files/test.txt')
self.assertEqual(res.status_code, 200)
self.assertEqual(res.headers['Content-Type'], 'text/plain')

res = Response.send_file('tests/files/test.txt.gz')
self.assertEqual(res.status_code, 200)
self.assertEqual(res.headers['Content-Type'], 'text/plain')
self.assertEqual(res.headers['Content-Encoding'], 'gzip')

def test_default_content_type(self):
original_content_type = Response.default_content_type
res = Response('foo')
Expand Down

0 comments on commit 58dd6c0

Please sign in to comment.