def test_map_to_type(self): factory = headerregistry.HeaderRegistry() h1 = factory('foobar', 'test') factory.map_to_type('foobar', headerregistry.UniqueUnstructuredHeader) h2 = factory('foobar', 'test') self.assertIsInstance(h1, headerregistry.BaseHeader) self.assertIsInstance(h1, headerregistry.UnstructuredHeader) self.assertIsInstance(h2, headerregistry.BaseHeader) self.assertIsInstance(h2, headerregistry.UniqueUnstructuredHeader)
class TestHeaderBase(TestEmailBase): factory = headerregistry.HeaderRegistry() def make_header(self, name, value): return self.factory(name, value)
def test_dont_use_default_map(self): factory = headerregistry.HeaderRegistry(use_default_map=False) h = factory('subject', 'test') self.assertIsInstance(h, headerregistry.BaseHeader) self.assertIsInstance(h, headerregistry.UnstructuredHeader)
def test_override_default_class_only_overrides_default(self): factory = headerregistry.HeaderRegistry(default_class=self.FooDefault) h = factory('subject', 'test') self.assertIsInstance(h, headerregistry.BaseHeader) self.assertIsInstance(h, headerregistry.UniqueUnstructuredHeader)
def test_override_default_class(self): factory = headerregistry.HeaderRegistry(default_class=self.FooDefault) h = factory('foobar', 'test') self.assertIsInstance(h, headerregistry.BaseHeader) self.assertIsInstance(h, self.FooDefault)
def test_override_default_base_class(self): factory = headerregistry.HeaderRegistry(base_class=self.FooBase) h = factory('foobar', 'test') self.assertIsInstance(h, self.FooBase) self.assertIsInstance(h, headerregistry.UnstructuredHeader)
def test_name_case_ignored(self): factory = headerregistry.HeaderRegistry() self.assertNotIn('Subject', factory.registry) h = factory('Subject', 'test') self.assertIsInstance(h, headerregistry.BaseHeader) self.assertIsInstance(h, headerregistry.UniqueUnstructuredHeader)
def test_arbitrary_name_unstructured(self): factory = headerregistry.HeaderRegistry() h = factory('foobar', 'test') self.assertIsInstance(h, headerregistry.BaseHeader) self.assertIsInstance(h, headerregistry.UnstructuredHeader)