コード例 #1
0
ファイル: test_update.py プロジェクト: AlexanderYAPPO/sahara
    def test_add_config_section(self):
        # conf here can't be a mock.Mock() because hasattr will
        # return true
        conf = Config()
        conf.register_group = mock.Mock()
        conf.register_opts = mock.Mock()

        template_api.set_conf(conf)
        opts = ["option"]

        # Named config section
        template_api.add_config_section("section", opts)

        conf.register_group.assert_called()
        config_group = conf.register_group.call_args[0][0]
        self.assertEqual("section", config_group.name)
        conf.register_opts.assert_called_with(opts, config_group)

        conf.register_group.reset_mock()
        conf.register_opts.reset_mock()

        # No config section, opts should be registered against
        # the default section
        template_api.add_config_section(None, opts)

        conf.register_group.assert_not_called()
        conf.register_opts.assert_called_with(opts)
コード例 #2
0
    def test_add_config_section(self):
        # conf here can't be a mock.Mock() because hasattr will
        # return true
        conf = Config()
        conf.register_group = mock.Mock()
        conf.register_opts = mock.Mock()

        template_api.set_conf(conf)
        opts = ["option"]

        # Named config section
        template_api.add_config_section("section", opts)

        self.assertEqual(1, conf.register_group.call_count)
        config_group = conf.register_group.call_args[0][0]
        self.assertEqual("section", config_group.name)
        self.assertEqual([mock.call(opts, config_group)],
                         conf.register_opts.call_args_list)

        conf.register_group.reset_mock()
        conf.register_opts.reset_mock()

        # No config section, opts should be registered against
        # the default section
        template_api.add_config_section(None, opts)

        conf.register_group.assert_not_called()
        conf.register_opts.assert_called_with(opts)