def test_load_driver(self, stevedore): stevedore.ExtensionManager.return_value = { "test": mock.MagicMock(obj=self.driver) } PackagingController._drivers = None controller = PackagingController.load("context", "test", "config") self.assertIs(self.driver, controller.driver) stevedore.ExtensionManager.assert_called_once_with( "packetary.packaging_drivers", invoke_on_load=True, invoke_args=("config",) )
def test_load_driver(self, stevedore): stevedore.ExtensionManager.return_value = { "test": mock.MagicMock(obj=self.driver) } PackagingController._drivers = None controller = PackagingController.load("context", "test", "config") self.assertIs(self.driver, controller.driver) stevedore.ExtensionManager.assert_called_once_with( "packetary.packaging_drivers", invoke_on_load=True, invoke_args=("config", ))
def create(cls, config, driver_type, driver_config): """Creates the packaging API instance. :param config: the global config :param driver_type: the name of driver which will be used :param driver_config: the config of driver :return PackagingApi instance """ context = config if isinstance(config, Context) else Context(config) return cls( PackagingController.load(context, driver_type, driver_config) )