コード例 #1
0
 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)
コード例 #2
0
class TestHeaderBase(TestEmailBase):
    factory = headerregistry.HeaderRegistry()

    def make_header(self, name, value):
        return self.factory(name, value)
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
 def test_arbitrary_name_unstructured(self):
     factory = headerregistry.HeaderRegistry()
     h = factory('foobar', 'test')
     self.assertIsInstance(h, headerregistry.BaseHeader)
     self.assertIsInstance(h, headerregistry.UnstructuredHeader)