forked from LBRYCommunity/lbry-sdk
add TestMimeTypes, pylint
This commit is contained in:
parent
652d7cbd24
commit
fc450eb164
2 changed files with 18 additions and 2 deletions
|
@ -154,5 +154,7 @@ types_map = {
|
|||
|
||||
def guess_media_type(path):
|
||||
_, ext = os.path.splitext(path)
|
||||
default = 'application/octet-stream' if not (ext and ext[1:].strip()) else f'application/x-ext-{ext[1:].strip().lower()}'
|
||||
return types_map.get(ext, default)
|
||||
return types_map.get(
|
||||
ext,
|
||||
'application/octet-stream' if not (ext and ext[1:].strip()) else f'application/x-ext-{ext[1:].strip().lower()}'
|
||||
)
|
||||
|
|
14
tests/unit/lbrynet_daemon/test_mime_types.py
Normal file
14
tests/unit/lbrynet_daemon/test_mime_types.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import unittest
|
||||
from lbrynet.extras.daemon import mime_types
|
||||
|
||||
|
||||
class TestMimeTypes(unittest.TestCase):
|
||||
def test_mp4_video(self):
|
||||
self.assertEqual("video/mp4", mime_types.guess_media_type("test.mp4"))
|
||||
|
||||
def test_x_ext_(self):
|
||||
self.assertEqual("application/x-ext-lbry", mime_types.guess_media_type("test.lbry"))
|
||||
|
||||
def test_octet_stream(self):
|
||||
self.assertEqual("application/octet-stream", mime_types.guess_media_type("test."))
|
||||
self.assertEqual("application/octet-stream", mime_types.guess_media_type("test"))
|
Loading…
Reference in a new issue