fix(2): F2-1 — test_custom_tests_repo_local_gated uses synthetic recipe (Adversary cold)
The Phase-1e HC2 test asserted custom_tests('custom-html', repo-local) == [] when only the
repo-local dir was set + custom-html had no cc-ci-side functional tests. Phase-2 commit bec9265
added 4 legitimate non-lifecycle test_*.py files under tests/custom-html/{functional,playwright}/
which custom_tests() now correctly returns — breaking the == [] assertion.
The custom_tests behavior is correct; the test fixture was using the real recipe name. Fix: switch
to a synthetic recipe + monkeypatch cc_ci_dir (same pattern already used in the Phase-2 sibling
test_discovery_phase2.py). 5-line change, no behavior change.
Cold-verifiable on cc-ci: cc-ci-run -m pytest tests/unit -v -> 21 passed in 5.38s
(Adversary's F2-1 repro now PASSes; no other regression).
Also: tests/n8n/PARITY.md drafted for the in-flight Q1.2 work (n8n parity port).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -70,18 +70,24 @@ def test_repo_local_wins_when_approved(tmp_path):
|
||||
assert res == ("repo-local", str(rl / "test_install.py"))
|
||||
|
||||
|
||||
def test_custom_tests_repo_local_gated(tmp_path):
|
||||
def test_custom_tests_repo_local_gated(tmp_path, monkeypatch):
|
||||
# non-lifecycle test_*.py from repo-local only count for approved recipes; lifecycle names excluded
|
||||
# Use a synthetic recipe name + monkeypatched cc_ci_dir so this is independent of what
|
||||
# tests/<real-recipe>/ ships (Phase-2 custom-html now also ships functional/ + playwright/,
|
||||
# which would legitimately appear in custom_tests for "custom-html" — F2-1).
|
||||
fake_recipe = "ccci-hc2-fixture"
|
||||
monkeypatch.setattr(discovery, "cc_ci_dir", lambda r: str(tmp_path / "cc-ci" / r))
|
||||
(tmp_path / "cc-ci" / fake_recipe).mkdir(parents=True)
|
||||
rl = tmp_path / "repo"
|
||||
rl.mkdir()
|
||||
(rl / "test_sso.py").write_text("# repo-local custom\n")
|
||||
(rl / "test_install.py").write_text("# lifecycle name -> excluded from custom\n")
|
||||
|
||||
_approve(tmp_path) # not approved -> repo-local custom ignored
|
||||
assert discovery.custom_tests("custom-html", str(rl)) == []
|
||||
assert discovery.custom_tests(fake_recipe, str(rl)) == []
|
||||
|
||||
_approve(tmp_path, "custom-html") # approved -> repo-local custom honored
|
||||
customs = discovery.custom_tests("custom-html", str(rl))
|
||||
_approve(tmp_path, fake_recipe) # approved -> repo-local custom honored
|
||||
customs = discovery.custom_tests(fake_recipe, str(rl))
|
||||
names = {(src, os.path.basename(p)) for src, p in customs}
|
||||
assert ("repo-local", "test_sso.py") in names
|
||||
assert all(os.path.basename(p) != "test_install.py" for _, p in customs)
|
||||
|
||||
Reference in New Issue
Block a user