# Path: gears/environment.py
# class MIMETypes(dict):
#     """The registry for MIME types. It acts like a dict with extensions as
#     keys and MIME types as values. Every registered extension can have only one
#     MIME type.
#     """
# 
#     def register_defaults(self):
#         """Register MIME types for ``.js`` and ``.css`` extensions."""
#         self.register('.css', 'text/css')
#         self.register('.js', 'application/javascript')
# 
#     def register(self, extension, mimetype):
#         """Register passed ``mimetype`` MIME type with ``extension`` extension.
#         """
#         self[extension] = mimetype
# 
#     def unregister(self, extension):
#         """Remove registered MIME type for passed ``extension`` extension. If
#         MIME type for this extension does not found in the registry, nothing
#         happens.
#         """
#         if extension in self:
#             del self[extension]


from gears.environment import MIMETypes
from unittest2 import TestCase


class MIMETypesTests(TestCase):

    def setUp(self):
        self.mimetypes = MIMETypes()
        self.mimetypes.register_defaults()

    def test_register(self):
        self.mimetypes.register('.txt', 'text/plain')
        self.assertIn('.txt', self.mimetypes)
        self.assertEqual(self.mimetypes['.txt'], 'text/plain')

    def test_unregister(self):
        self.assertIn('.css', self.mimetypes)
        self.mimetypes.unregister('.css')
        self.assertNotIn('.css', self.mimetypes)

    def test_get_if_exists(self):
        self.assertEqual(self.mimetypes.get('.css'), 'text/css')


# Path: gears/environment.py
# class MIMETypes(dict):
#     """The registry for MIME types. It acts like a dict with extensions as
#     keys and MIME types as values. Every registered extension can have only one
#     MIME type.
#     """
# 
#     def register_defaults(self):
#         """Register MIME types for ``.js`` and ``.css`` extensions."""
#         self.register('.css', 'text/css')
#         self.register('.js', 'application/javascript')
# 
#     def register(self, extension, mimetype):
#         """Register passed ``mimetype`` MIME type with ``extension`` extension.
#         """
#         self[extension] = mimetype
# 
#     def unregister(self, extension):
#         """Remove registered MIME type for passed ``extension`` extension. If
#         MIME type for this extension does not found in the registry, nothing
#         happens.
#         """
#         if extension in self:
#             del self[extension]


# Path: tests/test_environment_mimetypes.py
from gears.environment import MIMETypes
from unittest2 import TestCase



class MIMETypesTests(TestCase):

    def setUp(self):
        self.mimetypes = MIMETypes()
        self.mimetypes.register_defaults()

    def test_register(self):
        self.mimetypes.register('.txt', 'text/plain')
        self.assertIn('.txt', self.mimetypes)
        self.assertEqual(self.mimetypes['.txt'], 'text/plain')

    def test_unregister(self):
        self.assertIn('.css', self.mimetypes)
        self.mimetypes.unregister('.css')
        self.assertNotIn('.css', self.mimetypes)

    def test_get_if_exists(self):
        self.assertEqual(self.mimetypes.get('.css'), 'text/css')


    def test_get_if_does_not_exist(self):