add TestMimeTypes, pylint

This commit is contained in:
Jack Robison 2019-02-15 20:42:55 -05:00
parent 652d7cbd24
commit fc450eb164
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 18 additions and 2 deletions

View file

@ -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()}'
)

View 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"))