def test_read_yaml_file_or_yaml(tmpdir, from_file, config): expected = yaml.safe_load(config) if from_file: config_path = os.path.join(str(tmpdir), 'config.yaml') with open(config_path, 'w') as fp: fp.write(config) output = read_yaml_from_file_path(config_path, 'schemas/container.json') else: output = read_yaml(config, 'schemas/container.json') assert output == expected
def test_read_yaml_bad_package(caplog): with pytest.raises(ImportError): read_yaml("", 'schemas/container.json', package='bad_package') assert 'Unable to find package bad_package' in caplog.text
def test_valid_remote_sources_schema(config, expected_data): data = read_yaml(dedent(config), "schemas/container.json") assert expected_data == data
def test_read_yaml_validation_error(config, expected, caplog): with pytest.raises(OsbsValidationException) as exc_info: read_yaml(config, 'schemas/container.json') assert "schema validation error" in caplog.text assert expected == str(exc_info.value)
def test_invalid_remote_sources_schema(config, err_message, caplog): with pytest.raises(OsbsValidationException) as exc_info: read_yaml(dedent(config), "schemas/container.json") assert "schema validation error" in caplog.text assert re.search(err_message, str(exc_info.value))