diff --git a/BOARD.txt b/BOARD.txt index 8f603e9..af57e48 100644 --- a/BOARD.txt +++ b/BOARD.txt @@ -1,6 +1,5 @@ TODO ---------------------------------------- -more UT setup.py make client cert gen configurable diff --git a/bebop/tests/test_mime.py b/bebop/tests/test_mime.py new file mode 100644 index 0000000..54743b6 --- /dev/null +++ b/bebop/tests/test_mime.py @@ -0,0 +1,29 @@ +import unittest + +from ..mime import MimeType, DEFAULT_CHARSET, DEFAULT_MIME_TYPE + + +class TestMime(unittest.TestCase): + + def test_from_str(self): + self.assertIsNone(MimeType.from_str("")) + self.assertIsNone(MimeType.from_str("dumb")) + self.assertIsNone(MimeType.from_str("dumb;dumber")) + self.assertIsNone(MimeType.from_str("123456")) + + mime = MimeType.from_str("a/b") + self.assertEqual(mime.main_type, "a") + self.assertEqual(mime.sub_type, "b") + self.assertEqual(mime.parameters, {}) + + mime = MimeType.from_str("text/gemini") + self.assertEqual(mime.main_type, "text") + self.assertEqual(mime.sub_type, "gemini") + self.assertEqual(mime.parameters, {}) + + mime = MimeType.from_str("text/gemini;lang=en") + self.assertEqual(mime.main_type, "text") + self.assertEqual(mime.sub_type, "gemini") + self.assertEqual(mime.parameters, {"lang": "en"}) + mime = MimeType.from_str("text/gemini ;lang=en") + self.assertEqual(mime.parameters, {"lang": "en"})