The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: complete stamp writer contract consolidation
ethernetef3dd5967321
diff --git a/tests/installation/test_update_mechanism.py b/tests/installation/test_update_mechanism.pydeleted file mode 100644index 55ada0a31ee..00000000000--- a/tests/installation/test_update_mechanism.py+++ /dev/null@@ -1,69 +0,0 @@-"""The stamp's required ``updateMechanism`` field — the writer's contract.--Writer: scripts/write_install_stamp.py refuses to build a stamp without a-valid mechanism. Stamp readers HARD-FAIL a stamp missing the field: a-mechanism-less stamp is a build-lane bug, and guessing would misroute-updates for every install of that artifact. (The reader-side tests land-with the reader port; the build-lane pin tests land when the packager-lanes are wired to this writer.)-"""-import json-import subprocess-import sys-from pathlib import Path--import pytest--REPO_ROOT = Path(__file__).parent.parent.parent-sys.path.insert(0, str(REPO_ROOT / "scripts"))--from write_install_stamp import UPDATE_MECHANISMS, build_stamp # noqa: E402---class TestWriter:- @pytest.mark.parametrize("mechanism", UPDATE_MECHANISMS)- def test_valid_mechanisms_are_emitted(self, mechanism):- stamp = build_stamp(- commit="a" * 40, source="ci", update_mechanism=mechanism- )- assert stamp["updateMechanism"] == mechanism-- def test_invalid_mechanism_refused(self):- with pytest.raises(SystemExit):- build_stamp(commit="a" * 40, update_mechanism="carrier-pigeon")-- def test_mechanism_is_required_by_the_cli(self, tmp_path):- """argparse enforces --update-mechanism; a lane that forgets it dies."""- out = tmp_path / "install-stamp.json"- result = subprocess.run(- [- sys.executable,- str(REPO_ROOT / "scripts" / "write_install_stamp.py"),- "--output", str(out),- "--commit", "b" * 40,- ],- capture_output=True,- text=True,- timeout=30,- )- assert result.returncode != 0- assert "--update-mechanism" in result.stderr- assert not out.exists()-- def test_cli_emits_the_field(self, tmp_path):- out = tmp_path / "install-stamp.json"- result = subprocess.run(- [- sys.executable,- str(REPO_ROOT / "scripts" / "write_install_stamp.py"),- "--output", str(out),- "--commit", "c" * 40,- "--distribution", "docker",- "--update-mechanism", "external",- ],- capture_output=True,- text=True,- timeout=30,- )- assert result.returncode == 0, result.stderr- assert json.loads(out.read_text(encoding="utf-8-sig"))["updateMechanism"] == "external"diff --git a/tests/scripts/test_write_install_stamp.py b/tests/scripts/test_write_install_stamp.pyindex 60e613388d0..720b2a03ce3 100644--- a/tests/scripts/test_write_install_stamp.py+++ b/tests/scripts/test_write_install_stamp.py@@ -13,6 +13,7 @@ import pytest("bootstrap", "docker", "external", "bootstrap", None),("bundled", "desktop-app", "electron-updater", "bundled", "v0.18.0"),("bundled", "desktop-app", "app-installer", "bundled", "v0.18.0"),+ ("bundled", "desktop-app", "microsoft-store", "bundled", "v0.18.0"),("bundled", "desktop-app", "external", "bundled", "v0.18.0"),("light", "desktop-app", "electron-updater", "light", "v0.18.0"),])@@ -40,6 +41,24 @@ def test_cli_stamp_roundtrip(tmp_path, monkeypatch, variant, distribution, mechainfo = _stamp_version_info()assert info is not None and info.commit == "d" * 40assert _is_sealed(tmp_path)+ (tmp_path / ".git").mkdir()+ assert not _is_sealed(tmp_path), "a stamped source checkout is not sealed"++[email protected]("arguments", [[], ["--update-mechanism", "carrier-pigeon"]])+def test_missing_or_invalid_mechanism_cannot_emit_stamp(tmp_path, arguments):+ from scripts.write_install_stamp import build_stamp++ out = tmp_path / "install-stamp.json"+ result = subprocess.run(+ [sys.executable, str(Path(__file__).resolve().parents[2] / "scripts/write_install_stamp.py"),+ "--output", str(out), "--commit", "a" * 40, *arguments],+ capture_output=True, text=True, timeout=30,+ )+ assert result.returncode != 0 and "--update-mechanism" in result.stderr+ assert not out.exists()+ with pytest.raises(SystemExit, match="invalid --update-mechanism"):+ build_stamp(commit="a" * 40, update_mechanism=arguments[-1] if arguments else "")@pytest.mark.parametrize("variant,tag,error", [