def test_bool_valid(self): """ If the bool is valid, it should return successfully. """ config = get_basic_config(**{'setting_name': 'false'}) # This should not raise an Exception configuration_utils.validate_non_required_bool(config, 'setting_name')
def test_bool_not_set(self): """ If the bool is not set, it should be cool. """ config = get_basic_config() # This should not raise an Exception, since the setting is not required configuration_utils.validate_non_required_bool(config, 'setting_name')
def _validate_validate_downloads(config): """ This (humorously named) method will validate the optional config option called "validate_downloads". If it is set, it must be a boolean, otherwise it may be None. :param config: the config to be validated :type config: pulp.plugins.config.PluginCallConfiguration """ configuration_utils.validate_non_required_bool(config, importer_constants.KEY_VALIDATE)
def _validate_remove_missing_units(config): """ This method will validate the optional config setting called "remove_missing_units". If it is set, it must be a boolean, otherwise it may be None. :param config: the config to be validated :type config: pulp.plugins.config.PluginCallConfiguration """ configuration_utils.validate_non_required_bool(config, importer_constants.KEY_UNITS_REMOVE_MISSING)
def _validate_validate_downloads(config): """ This (humorously named) method will validate the optional config option called "validate_downloads". If it is set, it must be a boolean, otherwise it may be None. :param config: the config to be validated :type config: pulp.plugins.config.PluginCallConfiguration """ configuration_utils.validate_non_required_bool( config, importer_constants.KEY_VALIDATE)
def _validate_remove_missing_units(config): """ This method will validate the optional config setting called "remove_missing_units". If it is set, it must be a boolean, otherwise it may be None. :param config: the config to be validated :type config: pulp.plugins.config.PluginCallConfiguration """ configuration_utils.validate_non_required_bool( config, importer_constants.KEY_UNITS_REMOVE_MISSING)
def test_bool_not_valid(self): """ If the bool is not valid, it should return an error. """ config = get_basic_config(**{'setting_name': 'Not true or false.'}) try: configuration_utils.validate_non_required_bool(config, 'setting_name') self.fail('The validation should have failed, but it did not.') except configuration_utils.ValidationError, e: self.assertEqual(str(e), 'The configuration parameter <setting_name> may only be set to a ' 'boolean value, but is currently set to <Not true or false.>.')
def test_bool_not_valid(self): """ If the bool is not valid, it should return an error. """ config = get_basic_config(**{'setting_name': 'Not true or false.'}) try: configuration_utils.validate_non_required_bool( config, 'setting_name') self.fail('The validation should have failed, but it did not.') except configuration_utils.ValidationError, e: self.assertEqual( str(e), 'The configuration parameter <setting_name> may only be set to a ' 'boolean value, but is currently set to <Not true or false.>.')