def testGetPluginOf(self): """ Test the plugin query function. """ spm = PluginManager(categories_filter={ "Default": IPlugin, "IP": IPlugin, }, directories_list=[ os.path.join( os.path.dirname(os.path.abspath(__file__)), "plugins") ]) # load the plugins that may be found spm.collectPlugins() # check the getPluginsOfCategory self.assertEqual(len(spm.getPluginsOf(categories="IP")), 1) self.assertEqual(len(spm.getPluginsOf(categories="Default")), 1) self.assertEqual(len(spm.getPluginsOf(name="Simple Plugin")), 1) self.assertEqual(len(spm.getPluginsOf(is_activated=False)), 1) self.assertEqual( len(spm.getPluginsOf(categories="IP", is_activated=True)), 0) self.assertEqual( len(spm.getPluginsOf(categories="IP", is_activated=False)), 1) self.assertEqual(len(spm.getPluginsOf(categories="IP", pouet=False)), 0) self.assertEqual(len(spm.getPluginsOf(categories=["IP"])), 0) # The order in the categories are added to plugin info is random in this setup, hence the strange formula below self.assertEqual( len( spm.getPluginsOf(categories=["IP", "Default"]) | spm.getPluginsOf(categories=["Default", "IP"])), 1) self.assertEqual( len( spm.getPluginsOf(category="Default") | spm.getPluginsOf(category="IP")), 1)