aboutsummaryrefslogtreecommitdiff
path: root/server/szurubooru/tests/func/test_mime.py
diff options
context:
space:
mode:
authorrr-2016-08-14 11:47:58 +0200
committerrr-2016-08-14 16:43:35 +0200
commit264f9ee70b6bebc162a6152f0750aebfeb6f6b66 (patch)
treed38d7d9b778f2ef3e1c2ef3dada1d46e0397b548 /server/szurubooru/tests/func/test_mime.py
parentc23c401c4d0e83a6c0391dd2a8d6f6906ad9c172 (diff)
server/tests: update func.mime tests
Diffstat (limited to 'server/szurubooru/tests/func/test_mime.py')
-rw-r--r--server/szurubooru/tests/func/test_mime.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/szurubooru/tests/func/test_mime.py b/server/szurubooru/tests/func/test_mime.py
index 1d5a13a..eaf6989 100644
--- a/server/szurubooru/tests/func/test_mime.py
+++ b/server/szurubooru/tests/func/test_mime.py
@@ -9,10 +9,26 @@ from szurubooru.func import mime
('png.png', 'image/png'),
('jpeg.jpg', 'image/jpeg'),
('gif.gif', 'image/gif'),
+ ('text.txt', 'application/octet-stream'),
])
def test_get_mime_type(read_asset, input_path, expected_mime_type):
assert mime.get_mime_type(read_asset(input_path)) == expected_mime_type
+def test_get_mime_type_for_empty_file():
+ assert mime.get_mime_type(b'') == 'application/octet-stream'
+
+@pytest.mark.parametrize('mime_type,expected_extension', [
+ ('video/mp4', 'mp4'),
+ ('video/webm', 'webm'),
+ ('application/x-shockwave-flash', 'swf'),
+ ('image/png', 'png'),
+ ('image/jpeg', 'jpg'),
+ ('image/gif', 'gif'),
+ ('application/octet-stream', 'dat'),
+])
+def test_get_extension(mime_type, expected_extension):
+ assert mime.get_extension(mime_type) == expected_extension
+
@pytest.mark.parametrize('input_mime_type,expected_state', [
('application/x-shockwave-flash', True),
('APPLICATION/X-SHOCKWAVE-FLASH', True),

© 2015 - 2026 Jakob L. Kreuze