Exemplo n.º 1
0
    def test_list_opts_no_opts(self):
        expected_sections = self.base_sections
        # Set up the fake Stevedore extensions
        fake_extmanager_call = extension.ExtensionManager.make_test_instance(
            extensions=[
                extension.Extension(
                    name=fake_strategies.FakeDummy1Strategy2.get_name(),
                    entry_point="%s:%s" %
                    (fake_strategies.FakeDummy1Strategy2.__module__,
                     fake_strategies.FakeDummy1Strategy2.__name__),
                    plugin=fake_strategies.FakeDummy1Strategy2,
                    obj=None,
                )
            ],
            namespace="watcher_strategies",
        )

        def m_list_available(namespace):
            if namespace == "watcher_strategies":
                return fake_extmanager_call
            else:
                return extension.ExtensionManager.make_test_instance(
                    extensions=[], namespace=namespace)

        with mock.patch.object(extension, "ExtensionManager") as m_ext_manager:
            m_ext_manager.side_effect = m_list_available
            result = opts.list_opts()

        self.assertIsNotNone(result)
        for section_name, options in result:
            self.assertIn(section_name, expected_sections)
            self.assertTrue(len(options))
Exemplo n.º 2
0
    def test_list_opts_with_opts(self):
        expected_sections = self.base_sections + [
            'watcher_strategies.strategy_1']
        # Set up the fake Stevedore extensions
        fake_extmanager_call = extension.ExtensionManager.make_test_instance(
            extensions=[extension.Extension(
                name=fake_strategies.FakeDummy1Strategy1.get_name(),
                entry_point="%s:%s" % (
                    fake_strategies.FakeDummy1Strategy1.__module__,
                    fake_strategies.FakeDummy1Strategy1.__name__),
                plugin=fake_strategies.FakeDummy1Strategy1,
                obj=None,
            )],
            namespace="watcher_strategies",
        )

        def m_list_available(namespace):
            if namespace == "watcher_strategies":
                return fake_extmanager_call
            else:
                return extension.ExtensionManager.make_test_instance(
                    extensions=[], namespace=namespace)

        with mock.patch.object(extension, "ExtensionManager") as m_ext_manager:
            m_ext_manager.side_effect = m_list_available
            result = opts.list_opts()

        self.assertIsNotNone(result)
        self._assert_name_or_group(result, expected_sections)

        result_map = dict(result)
        strategy_opts = result_map['watcher_strategies.strategy_1']
        self.assertEqual(['test_opt'], [opt.name for opt in strategy_opts])
Exemplo n.º 3
0
    def test_run_list_opts(self):
        expected_sections = self.opt_sections

        result = opts.list_opts()

        self.assertIsNotNone(result)
        for section_name, options in result:
            self.assertIn(section_name, expected_sections)
            self.assertTrue(len(options))
Exemplo n.º 4
0
 def setUp(self):
     super(TestListOpts, self).setUp()
     self.base_sections = [
         'DEFAULT', 'api', 'database', 'watcher_decision_engine',
         'watcher_applier', 'watcher_planner', 'nova_client',
         'glance_client', 'cinder_client', 'ceilometer_client',
         'monasca_client', 'neutron_client', 'watcher_clients_auth'
     ]
     self.opt_sections = list(dict(opts.list_opts()).keys())
Exemplo n.º 5
0
    def setUp(self):
        super(TestListOpts, self).setUp()
        # These option groups will be registered using strings instead of
        # OptGroup objects this should be avoided if possible.
        self.none_objects = ['DEFAULT', 'watcher_clients_auth',
                             'watcher_strategies.strategy_1']

        self.base_sections = [
            'DEFAULT', 'api', 'database', 'watcher_decision_engine',
            'watcher_applier', 'watcher_datasources', 'watcher_planner',
            'nova_client', 'glance_client', 'gnocchi_client', 'grafana_client',
            'grafana_translators', 'cinder_client', 'ceilometer_client',
            'monasca_client', 'ironic_client', 'keystone_client',
            'neutron_client', 'watcher_clients_auth', 'collector',
            'placement_client']
        self.opt_sections = list(dict(opts.list_opts()).keys())