Esempio n. 1
0
    def test_load_driver_no_group(self, m_driver_manager):
        m_driver_manager.return_value = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverNoGroup.get_name(),
                entry_point="%s:%s" %
                (FakeDriverNoGroup.__module__, FakeDriverNoGroup.__name__),
                plugin=FakeDriverNoGroup,
                obj=None,
            ),
            namespace=FakeDriverNoGroup.namespace(),
        )

        loader_manager = DriverLoader(conf=cfg.CONF,
                                      namespace='',
                                      name='fake_no_group')
        loaded_driver = loader_manager.load()

        self.assertEqual(hasattr(loaded_driver, "test_opt"), True)
        self.assertEqual(loaded_driver.test_opt, "fake_no_group")
Esempio n. 2
0
    def setUp(self):
        super(TestDriverLoader, self).setUp()
        # To load the drivers without using the config file
        self.useFixture(ConfFixture())

        def _fake_parse(self, *args, **kw):
            return cfg.ConfigOpts._parse_cli_opts(cfg.CONF, [])

        cfg.CONF._parse_cli_opts = _fake_parse

        # First dependency to be returned
        self.no_group_driver_manager = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverNoGroup.get_name(),
                entry_point="%s:%s" % (FakeDriverNoGroup.__module__,
                                       FakeDriverNoGroup.__name__),
                plugin=FakeDriverNoGroup,
                obj=None,
            ),
            namespace=FakeDriverNoGroup.namespace(),
        )

        # 2nd dependency to be returned
        self.with_ext_opts_driver_manager = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverWithExternalOpts.get_name(),
                entry_point="%s:%s" % (FakeDriverWithExternalOpts.__module__,
                                       FakeDriverWithExternalOpts.__name__),
                plugin=FakeDriverWithExternalOpts,
                obj=None,
            ),
            namespace=FakeDriverWithExternalOpts.namespace(),
        )

        self.patches.extend([
            # patch.object(cfg, "ConfigOpts", ),
        ])

        # Applies all of our patches before each test
        for _patch in self.patches:
            _patch.start()
Esempio n. 3
0
    def setUp(self):
        super(TestDriverLoader, self).setUp()
        # To load the drivers without using the config file
        self.useFixture(ConfFixture())

        def _fake_parse(self, *args, **kw):
            return cfg.ConfigOpts._parse_cli_opts(cfg.CONF, [])

        cfg.CONF._parse_cli_opts = _fake_parse

        # First dependency to be returned
        self.no_group_driver_manager = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverNoGroup.get_name(),
                entry_point="%s:%s" %
                (FakeDriverNoGroup.__module__, FakeDriverNoGroup.__name__),
                plugin=FakeDriverNoGroup,
                obj=None,
            ),
            namespace=FakeDriverNoGroup.namespace(),
        )

        # 2nd dependency to be returned
        self.with_ext_opts_driver_manager = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverWithExternalOpts.get_name(),
                entry_point="%s:%s" % (FakeDriverWithExternalOpts.__module__,
                                       FakeDriverWithExternalOpts.__name__),
                plugin=FakeDriverWithExternalOpts,
                obj=None,
            ),
            namespace=FakeDriverWithExternalOpts.namespace(),
        )

        self.patches.extend([
            # patch.object(cfg, "ConfigOpts", ),
        ])

        # Applies all of our patches before each test
        for _patch in self.patches:
            _patch.start()
Esempio n. 4
0
    def test_load_driver_no_group(self, m_driver_manager):
        m_driver_manager.return_value = DriverManager.make_test_instance(
            extension=Extension(
                name=FakeDriverNoGroup.get_name(),
                entry_point="%s:%s" % (FakeDriverNoGroup.__module__,
                                       FakeDriverNoGroup.__name__),
                plugin=FakeDriverNoGroup,
                obj=None,
            ),
            namespace=FakeDriverNoGroup.namespace(),
        )

        loader_manager = DriverLoader(
            conf=cfg.CONF,
            namespace='',
            name='fake_no_group'
        )
        loaded_driver = loader_manager.load()

        self.assertEqual(hasattr(loaded_driver, "test_opt"), True)
        self.assertEqual(loaded_driver.test_opt, "fake_no_group")