Пример #1
0
    def test_file_add_remove(self):
        self.assertIn(self.config_1_name, config._config_files)
        self.assertIn(self.config_2_name, config._config_files)
        self.assertIn('section1', config.config.sections())
        self.assertIn('section2', config.config.sections())

        # remove a config, make sure the other one's still loaded
        config.remove_config_file(self.config_2_name)
        self.assertIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # remove both, make sure neither is loaded
        config.remove_config_file(self.config_1_name)
        self.assertNotIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # add a config back, make sure the other still isn't loaded
        config.add_config_file(self.config_1_name)
        self.assertIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # add the other config back, everything should be loaded again
        config.add_config_file(self.config_2_name)
        self.assertIn('section1', config.config.sections())
        self.assertIn('section2', config.config.sections())
Пример #2
0
    def test_file_add_remove(self):
        self.assertIn(self.config_1_name, config._config_files)
        self.assertIn(self.config_2_name, config._config_files)
        self.assertIn('section1', config.config.sections())
        self.assertIn('section2', config.config.sections())

        # remove a config, make sure the other one's still loaded
        config.remove_config_file(self.config_2_name)
        self.assertIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # remove both, make sure neither is loaded
        config.remove_config_file(self.config_1_name)
        self.assertNotIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # add a config back, make sure the other still isn't loaded
        config.add_config_file(self.config_1_name)
        self.assertIn('section1', config.config.sections())
        self.assertNotIn('section2', config.config.sections())

        # add the other config back, everything should be loaded again
        config.add_config_file(self.config_2_name)
        self.assertIn('section1', config.config.sections())
        self.assertIn('section2', config.config.sections())
Пример #3
0
def block_load_conf():
    # Remove server.conf from the list of autoloaded config files
    # This is needed when testing modules that create objects using conf data found in the
    # server config, such as DB connections, celery, etc. This should be used as little as
    # possible and as early as possible, before config file loads happen
    try:
        config.remove_config_file('/etc/pulp/server.conf')
    except RuntimeError:
        # server.conf already removed, move along...
        pass
Пример #4
0
def block_load_conf():
    # Remove server.conf from the list of autoloaded config files
    # This is needed when testing modules that create objects using conf data found in the
    # server config, such as DB connections, celery, etc. This should be used as little as
    # possible and as early as possible, before config file loads happen
    try:
        config.remove_config_file('/etc/pulp/server.conf')
    except RuntimeError:
        # server.conf already removed, move along...
        pass
Пример #5
0
    def test_file_add_remove_existing(self):
        self.assertIn(self.config_1_name, config._config_files)

        # add a file that's already in the config files list
        with self.assertRaises(RuntimeError) as cm:
            config.add_config_file(self.config_1_name)
        self.assertIn(self.config_1_name, cm.exception.args[0])
        self.assertIn('already in configuration files', cm.exception.args[0])

        # remove a file that isn't in the config files list
        config.remove_config_file(self.config_1_name)
        self.assertNotIn(self.config_1_name, config._config_files)

        with self.assertRaises(RuntimeError) as cm:
            config.remove_config_file(self.config_1_name)
        self.assertIn(self.config_1_name, cm.exception.args[0])
        self.assertIn('not in configuration files', cm.exception.args[0])
Пример #6
0
    def test_file_add_remove_existing(self):
        self.assertIn(self.config_1_name, config._config_files)

        # add a file that's already in the config files list
        with self.assertRaises(RuntimeError) as cm:
            config.add_config_file(self.config_1_name)
        self.assertIn(self.config_1_name, cm.exception.args[0])
        self.assertIn('already in configuration files', cm.exception.args[0])

        # remove a file that isn't in the config files list
        config.remove_config_file(self.config_1_name)
        self.assertNotIn(self.config_1_name, config._config_files)

        with self.assertRaises(RuntimeError) as cm:
            config.remove_config_file(self.config_1_name)
        self.assertIn(self.config_1_name, cm.exception.args[0])
        self.assertIn('not in configuration files', cm.exception.args[0])