test_tool_tree_refusal.py¶
tests/test_tool_tree_refusal.py
A grid refuses to measure a clew tree it cannot name.
test_a_clean_clew_tree_passes
None test_tool_tree_refusal.test_a_clean_clew_tree_passes()
A clean clew tree at a known commit passes.
tests/test_tool_tree_refusal.py:58
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_clean_clew_tree_passes → check_tool_tree → tool_identity → _substrate → compiled_languages |
Source · 7 lines
def test_a_clean_clew_tree_passes() -> None:
"""@brief Clean passes.
@version 1
"""
runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": False})
Activity · 1 steps
test_a_dirty_clew_tree_is_refused
None test_tool_tree_refusal.test_a_dirty_clew_tree_is_refused()
A modified clew tree is refused, and the refusal names the remedy.
tests/test_tool_tree_refusal.py:35
Checks
assert _SHA in str(raised.value), "the refusal does not name the commit it was measuring"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_a_dirty_clew_tree_is_refused → check_tool_tree → tool_identity → _substrate → compiled_languages |
Source · 9 lines
def test_a_dirty_clew_tree_is_refused() -> None:
"""@brief Dirty refuses.
@version 1
"""
with pytest.raises(ValueError, match="(?i)modified") as raised:
runner.check_tool_tree({"clew_commit": _SHA, "clew_dirty": True})
assert _SHA in str(raised.value), "the refusal does not name the commit it was measuring"
Activity · 3 steps
test_an_unknown_clew_tree_is_refused
None test_tool_tree_refusal.test_an_unknown_clew_tree_is_refused()
A clew tree git could not describe is refused.
tests/test_tool_tree_refusal.py:47
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_an_unknown_clew_tree_is_refused → check_tool_tree → tool_identity → _substrate → compiled_languages |
Source · 8 lines
def test_an_unknown_clew_tree_is_refused() -> None:
"""@brief Unknown refuses — absence is not cleanliness.
@version 1
"""
with pytest.raises(ValueError, match="(?i)cannot"):
runner.check_tool_tree({"clew_build_version": "9"})
Activity · 2 steps
test_generate_refuses_a_dirty_clew_tree
None test_tool_tree_refusal.test_generate_refuses_a_dirty_clew_tree(Path tmp_path, monkeypatch, capsys)
generate refuses before spending a cell when the clew tree is dirty.
tests/test_tool_tree_refusal.py:71
Checks
assert cli.cmd_generate(args) == 1assert not spent, f"{len(spent)} cell(s) were generated against a modified clew tree"assert "REFUSED" in capsys.readouterr().err
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_generate_refuses_a_dirty_clew_tree → cmd_generate → tool_identity → _substrate → compiled_languages |
Source · 28 lines
def test_generate_refuses_a_dirty_clew_tree(tmp_path: Path, monkeypatch, capsys) -> None:
"""THE TARGET CHECK IS STUBBED so the only reason left to refuse is the clew tree; without
that, a missing target checkout would return 1 and this test would pass for the wrong reason.
@brief generate refuses.
@version 1
"""
spent: list[str] = []
monkeypatch.setattr(cli, "check_revision", lambda *_a, **_k: None)
monkeypatch.setattr(cli, "run_cell", lambda cell, *_a, **_k: spent.append(cell.stem()))
monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})
args = cli.argparse.Namespace(
rubric=_MBEDTLS,
models=["claude-haiku-5-5"],
replicates=1,
seed=7,
repo=tmp_path / "repo",
out=tmp_path / "answers",
mcp_config=None,
timeout=60,
resume=False,
)
assert cli.cmd_generate(args) == 1
assert not spent, f"{len(spent)} cell(s) were generated against a modified clew tree"
assert "REFUSED" in capsys.readouterr().err
Activity · 8 steps
test_provision_refuses_a_dirty_clew_tree
None test_tool_tree_refusal.test_provision_refuses_a_dirty_clew_tree(Path tmp_path, monkeypatch)
provision refuses before fetching when the clew tree is dirty.
tests/test_tool_tree_refusal.py:104
Checks
assert not fetched, "the target was fetched for a clew tree that was going to be refused"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-PIPE-012 | inferred | test_provision_refuses_a_dirty_clew_tree → provision → write_provision_record → tool_identity → _substrate → compiled_languages |
Source · 14 lines
def test_provision_refuses_a_dirty_clew_tree(tmp_path: Path, monkeypatch) -> None:
"""BEFORE THE FETCH, because the fetch and the index build are the expensive steps and a
dirty tree makes both worthless.
@brief provision refuses.
@version 1
"""
fetched: list[Path] = []
monkeypatch.setattr(provision, "fetch_pinned", lambda _r, repo: fetched.append(repo))
monkeypatch.setattr(runner, "tool_identity", lambda: {"clew_commit": _SHA, "clew_dirty": True})
with pytest.raises(provision.ProvisionError, match="(?i)modified"):
provision.provision(load(_MBEDTLS), tmp_path / "mbedtls")
assert not fetched, "the target was fetched for a clew tree that was going to be refused"1 more lines, not shown