Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
def test_valid_remote_sources_schema(config, expected_data):
    data = read_yaml(dedent(config), "schemas/container.json")
    assert expected_data == data
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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))