def test_get_plugin_error(self): """ Test that we cannot activate a plugin which does not exist. """ BaseDataConnector.load_plugins('datasources/connectors') with self.assertRaises(KeyError): BaseDataConnector.get_plugin('thisplugindoesnotexist')
def setUp(self): from decouple import config BaseDataConnector.load_plugins('datasources/connectors') self.plugin = BaseDataConnector.get_plugin('HyperCat') self.api_key = config('HYPERCAT_CISCO_API_KEY') self.auth = None
def test_get_plugin_hypercat(self): """ Test that we have the HyperCat plugin and can activate it. """ BaseDataConnector.load_plugins('datasources/connectors') plugin = BaseDataConnector.get_plugin('HyperCat') self.assertIsNotNone(plugin)
def test_get_plugin_simple(self): """ Test that we have the plugin for trivial APIs and can activate it. """ BaseDataConnector.load_plugins('datasources/connectors') plugin = BaseDataConnector.get_plugin('DataSetConnector') self.assertIsNotNone(plugin)
def data_connector_class(self) -> typing.Type[BaseDataConnector]: """ Get the data connector class for this source. :return: Data connector class """ BaseDataConnector.load_plugins('datasources/connectors') try: plugin = BaseDataConnector.get_plugin(self.plugin_name) except KeyError as exc: if not self.plugin_name: raise ValueError('Data source plugin is not set') from exc raise KeyError('Data source plugin not found') from exc return plugin
def setUp(self): BaseDataConnector.load_plugins('datasources/connectors') self.plugin = BaseDataConnector.get_plugin('DataSetConnector')