test_guard_parent_catalogue.py¶
tests/guard/test_guard_parent_catalogue.py
A parent catalogue is checked when its clone is present, else reported unchecked (#73 item 3).
test_a_catalogue_not_marked_parent_still_refuses
None test_guard_parent_catalogue.test_a_catalogue_not_marked_parent_still_refuses(Path tmp_path, monkeypatch)
The default is unchanged: a missing pinned catalogue is an error naming it.
tests/guard/test_guard_parent_catalogue.py:65
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_catalogue_not_marked_parent_still_refuses → load_external_requirements → read_catalog_at → git_text → git_argv |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-027 | measured | test_a_catalogue_not_marked_parent_still_refuses → load_external_requirements |
Source · 8 lines
def test_a_catalogue_not_marked_parent_still_refuses(tmp_path: Path, monkeypatch) -> None: # noqa: ANN001
"""@brief The default is unchanged: a missing pinned catalogue is an error naming it."""
monkeypatch.chdir(tmp_path)
entry = {"name": "product", "repo": "../product", "rev": "abc123", "path": "requirements.yaml"}
with pytest.raises(RequirementsError):
load_external_requirements(_config(entry), [])
Activity · 4 steps
test_a_present_parent_is_checked_and_a_broken_link_is_a_violation
None test_guard_parent_catalogue.test_a_present_parent_is_checked_and_a_broken_link_is_a_violation(Path tmp_path, monkeypatch)
With the clone at the pin, links into it are checked as any other.
tests/guard/test_guard_parent_catalogue.py:73
Checks
assert unchecked == [] and "REQ-PRD-001" in knownassert len(found) == 1 and "REQ-PRD-999" in found[0].message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_present_parent_is_checked_and_a_broken_link_is_a_violation → load_external_requirements → read_catalog_at → git_text → git_argv |
| REQ-DDB-GUARD-027 | measured | test_a_present_parent_is_checked_and_a_broken_link_is_a_violation → load_external_requirements |
| REQ-DDB-SCHEMA-015 | measured | test_a_present_parent_is_checked_and_a_broken_link_is_a_violation → check_satisfies |
Source · 20 lines
def test_a_present_parent_is_checked_and_a_broken_link_is_a_violation(
tmp_path: Path, monkeypatch
) -> None: # noqa: ANN001
"""@brief With the clone at the pin, links into it are checked as any other."""
rev = _clone(tmp_path / "product", "requirements:\n REQ-PRD-001:\n name: Survives\n")
(tmp_path / "lib").mkdir()
monkeypatch.chdir(tmp_path / "lib")
unchecked: list[str] = []
entry = {
"name": "product",
"repo": "../product",
"rev": rev,
"path": "requirements.yaml",
"parent": True,
}
known = {"REQ-LIB-001", *load_external_requirements(_config(entry), unchecked)}
assert unchecked == [] and "REQ-PRD-001" in known
rows = {"REQ-LIB-001": {"satisfies": ["REQ-PRD-001", "REQ-PRD-999"]}}
found = check_satisfies(rows, known, "requirements.yaml", unchecked)
assert len(found) == 1 and "REQ-PRD-999" in found[0].message1 more lines, not shown
Activity · 10 steps
test_an_absent_parent_is_reported_unchecked_not_refused
None test_guard_parent_catalogue.test_an_absent_parent_is_reported_unchecked_not_refused(Path tmp_path, monkeypatch, caplog)
No clone: no error; its name is recorded; an unresolvable link is a warning.
tests/guard/test_guard_parent_catalogue.py:44
Checks
assert load_external_requirements(_config(entry), unchecked) == {}assert unchecked == ["product"]assert check_satisfies(rows, {"REQ-LIB-001"}, "requirements.yaml", unchecked) == []assert "REQ-PRD-001" in caplog.text and "unchecked" in caplog.text and "product" in caplog.text
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_absent_parent_is_reported_unchecked_not_refused → load_external_requirements → read_catalog_at → git_text → git_argv |
| REQ-DDB-GUARD-027 | measured | test_an_absent_parent_is_reported_unchecked_not_refused → load_external_requirements |
| REQ-DDB-SCHEMA-015 | measured | test_an_absent_parent_is_reported_unchecked_not_refused → check_satisfies |
Source · 21 lines
def test_an_absent_parent_is_reported_unchecked_not_refused(
tmp_path: Path, monkeypatch, caplog
) -> None: # noqa: ANN001
"""@brief No clone: no error; its name is recorded; an unresolvable link is a warning."""
monkeypatch.chdir(tmp_path)
unchecked: list[str] = []
entry = {
"name": "product",
"repo": "../product",
"rev": "abc123",
"path": "requirements.yaml",
"parent": True,
}
assert load_external_requirements(_config(entry), unchecked) == {}
assert unchecked == ["product"]
rows = {"REQ-LIB-001": {"satisfies": "REQ-PRD-001"}}
with caplog.at_level(logging.WARNING):
assert check_satisfies(rows, {"REQ-LIB-001"}, "requirements.yaml", unchecked) == []
assert "REQ-PRD-001" in caplog.text and "unchecked" in caplog.text and "product" in caplog.text