summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShyam Sunder <sgsunder1@gmail.com>2023-04-17 11:58:13 -0400
committerShyam Sunder <sgsunder1@gmail.com>2023-04-17 12:01:20 -0400
commit42524503b9fb5a73c69402c435e8d7aee3e036fa (patch)
tree2825c929382e5f89a7e94ba38a00109b76b1da71
parent8a03015349c3d9642c4d83472dbe76b072dd05a1 (diff)
client/tests: add unit tests for quicktime videos
-rw-r--r--server/szurubooru/func/mime.py9
-rw-r--r--server/szurubooru/tests/assets/mov.movbin0 -> 844 bytes
-rw-r--r--server/szurubooru/tests/func/test_mime.py4
3 files changed, 11 insertions, 2 deletions
diff --git a/server/szurubooru/func/mime.py b/server/szurubooru/func/mime.py
index 4aa9c3d..f01af0d 100644
--- a/server/szurubooru/func/mime.py
+++ b/server/szurubooru/func/mime.py
@@ -39,7 +39,7 @@ def get_mime_type(content: bytes) -> str:
if content[4:12] in (b"ftypisom", b"ftypiso5", b"ftypmp42", b"ftypM4V "):
return "video/mp4"
- if content[4:12] in (b"ftypqt "):
+ if content[4:12] == b"ftypqt ":
return "video/quicktime"
return "application/octet-stream"
@@ -69,7 +69,12 @@ def is_flash(mime_type: str) -> bool:
def is_video(mime_type: str) -> bool:
- return mime_type.lower() in ("application/ogg", "video/mp4", "video/quicktime", "video/webm")
+ return mime_type.lower() in (
+ "application/ogg",
+ "video/mp4",
+ "video/quicktime",
+ "video/webm",
+ )
def is_image(mime_type: str) -> bool:
diff --git a/server/szurubooru/tests/assets/mov.mov b/server/szurubooru/tests/assets/mov.mov
new file mode 100644
index 0000000..911ee85
--- /dev/null
+++ b/server/szurubooru/tests/assets/mov.mov
Binary files differ
diff --git a/server/szurubooru/tests/func/test_mime.py b/server/szurubooru/tests/func/test_mime.py
index b33746b..551ba7c 100644
--- a/server/szurubooru/tests/func/test_mime.py
+++ b/server/szurubooru/tests/func/test_mime.py
@@ -7,6 +7,7 @@ from szurubooru.func import mime
"input_path,expected_mime_type",
[
("mp4.mp4", "video/mp4"),
+ ("mov.mov", "video/quicktime"),
("webm.webm", "video/webm"),
("flash.swf", "application/x-shockwave-flash"),
("png.png", "image/png"),
@@ -35,6 +36,7 @@ def test_get_mime_type_for_empty_file():
[
("video/mp4", "mp4"),
("video/webm", "webm"),
+ ("video/quicktime", "mov"),
("application/x-shockwave-flash", "swf"),
("image/png", "png"),
("image/jpeg", "jpg"),
@@ -70,6 +72,8 @@ def test_is_flash(input_mime_type, expected_state):
("VIDEO/WEBM", True),
("video/mp4", True),
("VIDEO/MP4", True),
+ ("video/quicktime", True),
+ ("VIDEO/QUICKTIME", True),
("video/anything_else", False),
("application/ogg", True),
("not a video", False),