Files
graphify/tests/test_install_version_stamp.py
T
Ousama Ben YounesandClaude Opus 4.8 a59a4e812e fix(install): stamp .graphify_version only for the platform being installed (#2694)
install() called _refresh_all_version_stamps(), which stamped every installed
platform's .graphify_version with the current version WITHOUT rewriting that
platform's skill content — so a genuinely stale platform was stamped current
and its staleness warning was suppressed. Removes that bogus refresh; each
platform's stamp now advances only when its own content is (re)written via
_copy_skill_file, so a not-reinstalled stale platform correctly still warns.
Completes #2694 (part 1 shipped in 0.9.44 via #2753).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-16 18:30:13 +01:00

50 lines
2.2 KiB
Python

"""Regression test for #2694 (version-stamp half).
`graphify install --platform X` must only advance `.graphify_version` for the
platform whose skill content it actually (re)writes. Previously it also bumped
the stamp of every *other* already-installed platform, so a platform whose
SKILL.md was left untouched carried a current stamp and its "skill is from
graphify A, package is B" staleness warning was suppressed even though the
content really was stale.
"""
from __future__ import annotations
from unittest.mock import patch
import graphify.__main__ as mainmod
# A prior graphify version stamped into an unrelated, not-reinstalled platform.
_STALE_STAMP = "0.0.1-old"
def test_install_does_not_bump_other_platforms_stamp(tmp_path, monkeypatch):
"""Installing one platform must leave a different, already-installed
platform's `.graphify_version` untouched, so its staleness warning stays
truthful (#2694)."""
home = tmp_path / "home"
home.mkdir()
monkeypatch.chdir(tmp_path)
monkeypatch.setattr(mainmod, "_check_skill_version", lambda _: None)
with patch("graphify.__main__.Path.home", return_value=home):
# Simulate "codex" installed earlier at a stale version: its SKILL.md
# content is old, and its stamp reflects that old version.
codex_skill = mainmod._platform_skill_destination("codex", project=False)
codex_skill.parent.mkdir(parents=True, exist_ok=True)
codex_skill.write_text("stale skill body", encoding="utf-8")
codex_stamp = codex_skill.parent / ".graphify_version"
codex_stamp.write_text(_STALE_STAMP, encoding="utf-8")
# Upgrade only the claude platform.
mainmod.install("claude")
# The platform we installed is stamped at the current version...
claude_skill = mainmod._platform_skill_destination("claude", project=False)
assert (claude_skill.parent / ".graphify_version").read_text() == mainmod.__version__
# ...but the untouched codex platform keeps its stale stamp, so its
# refresh warning still fires.
assert codex_stamp.read_text() == _STALE_STAMP, (
"installing claude must not advance codex's version stamp (#2694)"
)