def test_plugin_bad_config_file(plugin_config_file): with pytest.raises(exceptions.UserError) as err_info: validator = PluginValidator(plugin_config_file, const.PLUGIN_CONFIG_SCHEMA) validator.validate_plugin_config() message = err_info.value.message assert message == ("Unable to read plugin config file '{}'" "\nError code: 2. Error message: No such file or" " directory".format(plugin_config_file))
def validate_plugin_config_file(plugin_config, stop_build): """ Reads a plugin config file and validates the contents using a pre-defined schema. If stop_build is True, will report exception back, otherwise warnings. Returns: On successful validation, returns content of the plugin config. """ validation_mode = (ValidationMode.ERROR if stop_build else ValidationMode.WARNING) validator = PluginValidator(plugin_config, const.PLUGIN_CONFIG_SCHEMA) with validate_error_handler(plugin_config, validation_mode): validator.validate_plugin_config() return validator.result