def testMissingAttribute(self): """ Test the parsing when attributes are missing, should get exceptions """ config_file = get_test_config("rsv/rsv2.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR settings.parse_configuration(configuration) mandatory = ['enable_nagios'] for option in mandatory: config_file = get_test_config("rsv/rsv1.ini") configuration = configparser.SafeConfigParser() configuration.read(config_file) configuration.remove_option('RSV', option) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR self.assertRaises(exceptions.SettingError, settings.parse_configuration, configuration)
def load_settings_from_files(self, *cfgfiles): configuration = configparser.SafeConfigParser() for cfgfile in cfgfiles: configuration.read(get_test_config(cfgfile)) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR settings.parse_configuration(configuration) return settings
def load_settings_from_files(self, *cfgfiles): configuration = ConfigParser.SafeConfigParser() for cfgfile in cfgfiles: configuration.read(get_test_config(cfgfile)) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
def testGram(self): """ Test RSV config no longer accepts gram_ce_hosts """ config_parser = ConfigParser.SafeConfigParser() config_file = get_test_config("rsv/rsv_gram.ini") config_parser.read(config_file) settings = rsv.RsvConfiguration(logger=global_logger) settings.parse_configuration(config_parser) self.assertFalse(settings.check_attributes(settings.get_attributes()), "gram_ce_hosts incorrectly flagged as correct")
def testMissingAttribute(self): """ Test the parsing when attributes are missing, should get exceptions """ # need to have rsv installed to get rsv tests working if not utilities.rpm_installed('rsv-core'): return config_file = get_test_config("rsv/rsv2.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e)
settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR try: settings.parse_configuration(configuration) except Exception, e: self.fail("Received exception while parsing configuration: %s" % e) mandatory = ['enable_gratia', 'enable_nagios'] for option in mandatory: config_file = get_test_config("rsv/rsv1.ini") configuration = ConfigParser.SafeConfigParser() configuration.read(config_file) configuration.remove_option('RSV', option) settings = rsv.RsvConfiguration(logger=global_logger) settings.rsv_meta_dir = RSV_META_DIR self.assertRaises(exceptions.SettingError, settings.parse_configuration, configuration) def testInvalidKey(self): """ Test the check_attributes with invalid key file """ # need to have rsv installed to get rsv tests working if not utilities.rpm_installed('rsv-core'): return settings = self.load_settings_from_files("rsv/invalid_key.ini") attributes = settings.get_attributes() self.assertFalse(settings.check_attributes(attributes),