def test_plugin_manager_empty(self, mock): pm = PluginManager() pm._plugins_ = {"test.a": basePlugin(), "test.b": basePlugin()} plugins_inst = pm.get_plugins() plugins = pm.get_plugins(instance=False) plugins_from_pkg = pm.get_plugins(package="test.", instance=False) self.assertEqual(len(plugins), 2) self.assertEqual(len(plugins_inst), 2) self.assertEqual(len(plugins_from_pkg), 2)
def test_register(self): mock_dependency = MagicMock() mock_dependency.verify = MagicMock() class basePlugin(BasePlugin): _name_ = "name" _description_ = "desc" _author_ = "author" _version_ = 1 _dependencies_ = [mock_dependency] def __init__(self): PluginManager().register_plugin(self) pm = PluginManager() pm._plugins_ = {} bp = basePlugin() self.assertEqual(len(pm.get_plugins()), 1) mock_dependency.verify.assert_called_once()