server/tests: update func.mime tests
This commit is contained in:
parent
c23c401c4d
commit
264f9ee70b
3 changed files with 18 additions and 0 deletions
|
@ -33,6 +33,7 @@ def get_extension(mime_type):
|
|||
'image/png': 'png',
|
||||
'video/mp4': 'mp4',
|
||||
'video/webm': 'webm',
|
||||
'application/octet-stream': 'dat',
|
||||
}
|
||||
return extension_map.get((mime_type or '').strip().lower(), None)
|
||||
|
||||
|
|
1
server/szurubooru/tests/assets/text.txt
Normal file
1
server/szurubooru/tests/assets/text.txt
Normal file
|
@ -0,0 +1 @@
|
|||
hello
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue