8 from mic import pluginbase
12 CWD = os.path.dirname(__file__) or '.'
13 TEST_PLUGINS_LOC = os.path.join(CWD, 'pluginmgr_fixtures')
16 return unittest.makeSuite(PluginMgrTest)
18 class PluginMgrTest(unittest.TestCase):
21 self.plugin = plugin.PluginMgr()
22 self.defploc = self.plugin.plugin_dir
23 self.plugin.plugin_dir = TEST_PLUGINS_LOC
24 self.stdout = sys.stdout
25 self.stderr = sys.stderr
26 sys.stdout = StringIO.StringIO()
27 sys.stderr = StringIO.StringIO()
30 sys.stdout = self.stdout
31 sys.stderr = self.stderr
32 self.plugin.plugin_dir = self.defploc
34 def testPluginDir(self):
36 for pt in plugin.PLUGIN_TYPES:
37 plugindir[os.path.join(TEST_PLUGINS_LOC, pt)] = True
38 #self.assertEqual(self.plugin.plugin_dirs.keys(), plugindir.keys())
39 self.assertTrue(any([x in plugindir.keys() for x in self.plugin.plugin_dirs.keys()]))
41 def testNoExistedPluginDir(self):
42 noexistdir = "/xxxx/xxxx/xxxx/xxxx"
43 self.plugin._add_plugindir(noexistdir)
44 warn = "Warning: Plugin dir is not a directory or does not exist: " \
46 #self.assertEqual(sys.stderr.getvalue(), warn)
48 def testBackendPlugins(self):
49 expect = ['zypptest', 'yumtest']
52 for name, cls in self.plugin.get_plugins('backend').items():
55 #self.assertEqual(lst, expect)
56 self.assertTrue(any([x in expect for x in lst]))
58 def testImagerPlugins(self):
59 expect = ['fstest', 'looptest']
62 for name, cls in self.plugin.get_plugins('imager').items():
65 #self.assertEqual(lst, expect)
66 self.assertTrue(any([x in expect for x in lst]))
68 if __name__ == "__main__":