This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Bebop/bebop/tests/test_mime.py

30 lines
1 KiB
Python
Raw Normal View History

2021-05-29 15:24:11 +02:00
import unittest
2021-06-01 21:40:41 +02:00
from ..mime import MimeType
2021-05-29 15:24:11 +02:00
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"})