Exemple #1
0
def test_specs_from_file__local_package_no_package_dir(tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text(f"""
[packages]

[packages.test]
type = "local"
xml_subdir = "xml"
include_subdir = "include"
""")

    with pytest.raises(SpecificationError):
        specs_from_file(spec_file)
Exemple #2
0
def test_specs_from_file__source__unknown(tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text("""
[sources]


[packages]

[packages.test]
source = "http"
version = "1.0.0"
""")

    with pytest.raises(SpecificationError):
        specs_from_file(spec_file)
Exemple #3
0
def test_specs_from_file__http_package__no_version(tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text("""
[packages]

[packages.test]
type = "http"
xml_subdir = "xml"
include_subdir = "include"
url_template = "https://example.com/{version}"
file_names = [ "xml.tar.gz" ]
""")

    with pytest.raises(SpecificationError):
        specs_from_file(spec_file)
Exemple #4
0
def test_specs_from_file__source__override_partial(tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text("""
[sources]

[sources.http]
type = "http"
xml_subdir = "xml"
include_subdir = "include"
url_template = "https://example.com/{version}"
file_names = [ "xml.tar.gz" ]


[packages]

[packages.test]
source = "http"
xml_subdir = "doxygen"
include_subdir = "adoc"
version = "1.0.0"
""")

    specs = specs_from_file(spec_file)
    assert len(specs) == 1

    spec = specs[0]
    assert spec.name == "test"
    assert isinstance(spec, HttpPackageSpec)
    assert spec.xml_subdir == "doxygen"
    assert spec.include_subdir == "adoc"
    assert spec.url_template == "https://example.com/{version}"
    assert spec.file_names == ["xml.tar.gz"]
    assert spec.version == "1.0.0"
Exemple #5
0
def test_specs_from_file__http_package__with_version_file__spec_override(
        tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text("""
[packages]

[packages.test]
type = "http"
xml_subdir = "xml"
include_subdir = "include"
url_template = "https://example.com/{version}"
file_names = [ "xml.tar.gz" ]
version = "15.2.1"
""")

    version_file = tmp_path / "versions.csv"
    version_file.write_text("""Component name,Version
test0,3.0.0
test,1.5.8
test43,1.2.3
""")

    specs = specs_from_file(spec_file, version_file)
    assert len(specs) == 1

    spec = specs[0]
    assert spec.name == "test"
    assert isinstance(spec, HttpPackageSpec)
    assert spec.xml_subdir == "xml"
    assert spec.include_subdir == "include"
    assert spec.url_template == "https://example.com/{version}"
    assert spec.file_names == ["xml.tar.gz"]
    assert spec.version == "15.2.1"
Exemple #6
0
def test_specs_from_file__no_type(tmp_path):
    spec_file = tmp_path / "spec.toml"
    package_dir = tmp_path / "package"
    spec_file.write_text(f"""
[packages]

[packages.test]
xml_subdir = "xml"
include_subdir = "include"
file_names = [ "xml.tar.gz" ]
url_template = "https://example.com/{{version}}"
version = "1.0.0"
package_dir = "{package_dir}"
""")

    with pytest.raises(SpecificationError):
        specs_from_file(spec_file)
Exemple #7
0
def test_specs_from_file__http_package__with_version_file__version_missing(
        tmp_path):
    spec_file = tmp_path / "spec.toml"
    spec_file.write_text("""
[packages]

[packages.test]
type = "http"
xml_subdir = "xml"
include_subdir = "include"
url_template = "https://example.com/{version}"
file_names = [ "xml.tar.gz" ]
""")

    version_file = tmp_path / "versions.csv"
    version_file.write_text("""Component name,Version
test0,3.0.0
test43,1.2.3
""")

    with pytest.raises(SpecificationError):
        specs_from_file(spec_file, version_file)
Exemple #8
0
def test_specs_from_file__local_package(tmp_path):
    spec_file = tmp_path / "spec.toml"
    package_dir = tmp_path / "package"
    spec_file.write_text(f"""
[packages]

[packages.test]
type = "local"
xml_subdir = "xml"
include_subdir = "include"
package_dir = "{package_dir}"
""")

    specs = specs_from_file(spec_file)
    assert len(specs) == 1

    spec = specs[0]
    assert spec.name == "test"
    assert isinstance(spec, LocalPackageSpec)
    assert spec.xml_subdir == "xml"
    assert spec.include_subdir == "include"
    assert spec.package_dir == package_dir