from pathlib import Path import tempfile import pytest from tools.manifest_cli import create_snapshot, lint ROOT = Path(__file__).resolve().parents[1] def test_product_manifest_has_exact_repository_set() -> None: projects = lint(ROOT / "manifests/products/6400-front-rear.xml") assert {item.get("name") for item in projects} == { "engineering-manifests", "cpld-temperature-control", "hth-platform", "thermal-control-lab", } def test_legacy_manifest_is_minimal() -> None: projects = lint(ROOT / "manifests/products/legacy-door-percent.xml") assert {item.get("name") for item in projects} == { "engineering-manifests", "cpld-temperature-control", } def test_duplicate_project_is_rejected() -> None: with tempfile.TemporaryDirectory() as directory: path = Path(directory) / "bad.xml" path.write_text( '', encoding="utf-8", ) with pytest.raises(ValueError, match="duplicate"): lint(path) def test_floating_snapshot_is_rejected() -> None: with tempfile.TemporaryDirectory() as directory: path = Path(directory) / "bad.xml" path.write_text( '', encoding="utf-8", ) with pytest.raises(ValueError, match="full SHA"): lint(path, snapshot=True) def test_snapshot_output_inside_snapshotted_repository_is_rejected() -> None: with pytest.raises(ValueError, match="outside every snapshotted repository"): create_snapshot( ROOT / "manifests/products/6400-front-rear.xml", ROOT / "manifests/snapshots/6400-front-rear/development.xml", )