Beispiel #1
0
 def test_builtins(self) -> None:
     """Test each builtin for the usual plugin needs
     """
     builtins = KnownImageCrawlers._builtins()
     for _, bi_class in builtins.items():
         KnownImageCrawlers._test(bi_class)
     self.assertTrue(True, 'no exceptions thrown')
Beispiel #2
0
 def test_items(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('test', LoadableImageCrawlerA)]
     # act
     ic_items = kic.items()
     # arrange
     self.assertListEqual(kic._list, [i for i in ic_items])
Beispiel #3
0
 def test_classes(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('test', LoadableImageCrawlerA)]
     # act
     ic_classes = kic.classes()
     # arrange
     self.assertListEqual([LoadableImageCrawlerA], [c for c in ic_classes])
Beispiel #4
0
 def test_raise(self) -> None:
     # arrange
     known_ic_name = 'test'
     kic = KnownImageCrawlers([])
     kic._list = [(known_ic_name, LoadableImageCrawlerA)]
     # act & assert
     with self.assertRaises(KeyError):
         kic._test_duplicate_name(known_ic_name)
Beispiel #5
0
 def test_raise(self) -> None:
     # arrange
     known_ic_class = LoadableImageCrawlerA
     kic = KnownImageCrawlers([])
     kic._list = [('test', known_ic_class)]
     # act & assert
     with self.assertRaises(TypeError):
         kic._test_duplicate_class(known_ic_class)
Beispiel #6
0
 def test_success_empty(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = []
     # act
     kic._test_duplicate_name('test')
     # assert
     self.assertTrue(True, 'no errors thrown')
Beispiel #7
0
 def test_success_filled(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('testA', LoadableImageCrawlerA)]
     # act
     kic._test_duplicate_name('testB')
     # assert
     self.assertTrue(True, 'no errors thrown')
Beispiel #8
0
 def test_names(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('test', LoadableImageCrawlerA)]
     # act
     ic_names = kic.names()
     # arrange
     self.assertListEqual(['test'], [n for n in ic_names])
Beispiel #9
0
 def test_success(self) -> None:
     kic = KnownImageCrawlers([])
     kic._list = []
     # act
     kic._add(_TEST_PLUGIN_ENTRY)
     # arrange
     self.assertListEqual([(_TEST_PLUGIN_ENTRY.name, _TEST_PLUGIN_CLASS)],
                          kic._list)
Beispiel #10
0
 def test_raise(self) -> None:
     # arrange
     entry = EntryPoint('Test',
                        '__.does.not.exist',
                        attrs=('UnknownClass', ),
                        dist=_TEST_PLUGIN_DIST)
     # act & assert
     with self.assertRaises(ImportError):
         KnownImageCrawlers._load(entry)
Beispiel #11
0
 def test_get_name(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('testKnown', LoadableImageCrawlerA)]
     # act
     ic_name_known = kic.get_name(LoadableImageCrawlerA)
     ic_name_unknown = kic.get_name(LoadableImageCrawlerB)
     # arrange
     self.assertEqual('testKnown', ic_name_known)
     self.assertIsNone(ic_name_unknown)
Beispiel #12
0
 def test_get_class(self) -> None:
     # arrange
     kic = KnownImageCrawlers([])
     kic._list = [('testKnown', LoadableImageCrawlerA)]
     # act
     ic_class_known = kic.get_class('testKnown')
     ic_class_unknown = kic.get_class('testUnknown')
     # arrange
     self.assertIs(LoadableImageCrawlerA, ic_class_known)
     self.assertIsNone(ic_class_unknown)
Beispiel #13
0
 def test_success(self) -> None:
     # arrange
     entry = _TEST_PLUGIN_ENTRY
     # act
     loaded = KnownImageCrawlers._load(entry)
     # assert
     self.assertIs(_TEST_PLUGIN_CLASS, loaded)
Beispiel #14
0
 def test_raise(self) -> None:
     # act & assert
     with self.assertRaises(TypeError):
         KnownImageCrawlers._test_abstract(BaseLoadableImageCrawlerA)
Beispiel #15
0
 def test_success_inherited(self) -> None:
     # act
     KnownImageCrawlers._test_abstract(LoadableImageCrawlerA)
     # assert
     self.assertTrue(True, 'no errors thrown')
Beispiel #16
0
 def test_success(self) -> None:
     # act
     KnownImageCrawlers._test_abstract(StandaloneLoadableImageCrawlerA)
     # assert
     self.assertTrue(True, 'no errors thrown')
Beispiel #17
0
 def test_raise(self) -> None:
     # act & assert
     with self.assertRaises(TypeError):
         KnownImageCrawlers._test_inheritance(
             StandaloneLoadableImageCrawlerA)