test_guard_dependency_coverage.py¶
tests/guard/test_guard_dependency_coverage.py
Coverage through pinned dependencies, opt-in (#73 item 2, 2.1).
test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it
None test_guard_dependency_coverage.test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it(tmp_path, monkeypatch)
Tagged at the pin → covered via; exempt by this repo's rules → covered via; else uncovered.
tests/guard/test_guard_dependency_coverage.py:65
Checks
assert report["covered_via"] == [assert report["uncovered"] == ["REQ-PRD-002"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion |
| REQ-DDB-GUARD-011 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → load_config |
| REQ-DDB-GUARD-013 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → find_source_files |
| REQ-DDB-GUARD-016 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content |
| REQ-DDB-GUARD-019 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-022 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage |
| REQ-DDB-GUARD-024 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-027 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → covered_via → read_catalog_at |
| REQ-DDB-PIPE-011 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file |
| REQ-DDB-SCHEMA-015 | measured | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → covered_via → _realised → link_ids |
| REQ-DDB-WIKI-054 | inferred | test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 14 lines
def test_a_requirement_implemented_by_a_dependency_at_its_pin_is_covered_via_it(
tmp_path, monkeypatch
) -> None: # noqa: ANN001
"""@brief Tagged at the pin → covered via; exempt by this repo's rules → covered via; else uncovered."""
product = _setup(tmp_path, through=True)
monkeypatch.chdir(product)
report = analyze_coverage(["src"], load_config(product / ".clew.yaml"))
assert report["covered_via"] == [
{"req_id": "REQ-PRD-001", "via": "lib:REQ-LIB-001", "how": "implemented"},
{"req_id": "REQ-PRD-003", "via": "lib:REQ-LIB-003", "how": "exempt"},
]
assert report["uncovered"] == ["REQ-PRD-002"]
Activity · 5 steps
test_off_by_default_nothing_changes
None test_guard_dependency_coverage.test_off_by_default_nothing_changes(tmp_path, monkeypatch)
Without the option every one stays uncovered, and `covered_via` is absent.
tests/guard/test_guard_dependency_coverage.py:79
Checks
assert "covered_via" not in reportassert report["uncovered"] == ["REQ-PRD-001", "REQ-PRD-002", "REQ-PRD-003"]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_off_by_default_nothing_changes → analyze_coverage → covered_via → read_catalog_at → git_text → git_argv |
| REQ-DDB-CONFIG-009 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion |
| REQ-DDB-GUARD-011 | measured | test_off_by_default_nothing_changes → analyze_coverage → load_requirements_full |
| REQ-DDB-GUARD-012 | measured | test_off_by_default_nothing_changes → load_config |
| REQ-DDB-GUARD-013 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → find_source_files |
| REQ-DDB-GUARD-016 | measured | test_off_by_default_nothing_changes → analyze_coverage → load_requirements_full → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content |
| REQ-DDB-GUARD-019 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → parse_doxygen_tags |
| REQ-DDB-GUARD-020 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _find_preceding_doxygen → _find_python_docstring_block |
| REQ-DDB-GUARD-022 | measured | test_off_by_default_nothing_changes → analyze_coverage |
| REQ-DDB-GUARD-024 | measured | test_off_by_default_nothing_changes → load_config → apply_opt_in_languages |
| REQ-DDB-GUARD-025 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → _process_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-027 | inferred | test_off_by_default_nothing_changes → analyze_coverage → covered_via → read_catalog_at |
| REQ-DDB-PIPE-011 | measured | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → binary_file |
| REQ-DDB-SCHEMA-015 | inferred | test_off_by_default_nothing_changes → analyze_coverage → covered_via → _realised → link_ids |
| REQ-DDB-WIKI-054 | inferred | test_off_by_default_nothing_changes → analyze_coverage → collect_tagged_functions → find_source_files → gate_exclusion → _gate_matcher → load_toolchain_config → _string_list → all |
Source · 9 lines
def test_off_by_default_nothing_changes(tmp_path, monkeypatch) -> None: # noqa: ANN001
"""@brief Without the option every one stays uncovered, and `covered_via` is absent."""
product = _setup(tmp_path, through=False)
monkeypatch.chdir(product)
report = analyze_coverage(["src"], load_config(product / ".clew.yaml"))
assert "covered_via" not in report
assert report["uncovered"] == ["REQ-PRD-001", "REQ-PRD-002", "REQ-PRD-003"]
Activity · 5 steps
test_the_reports_say_which_dependency_covered_it
None test_guard_dependency_coverage.test_the_reports_say_which_dependency_covered_it()
Text and Markdown list each "via"; neither mentions it when the option is off.
tests/guard/test_guard_dependency_coverage.py:88
Checks
assert "REQ-A via lib:REQ-L-1 (implemented)" in format_coverage_text(via)assert "- REQ-A via lib:REQ-L-1 (implemented)" in format_coverage_markdown(via)assert "via" not in format_coverage_text(base) and "via" not in format_coverage_markdown(base)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-022 | measured | test_the_reports_say_which_dependency_covered_it → format_coverage_text |
Source · 17 lines
def test_the_reports_say_which_dependency_covered_it() -> None:
"""@brief Text and Markdown list each "via"; neither mentions it when the option is off."""
from clew.guard.coverage import format_coverage_markdown, format_coverage_text
base = {
"covered": [],
"total_requirements": 2,
"uncovered": ["REQ-B"],
"exempt": [],
"orphan_refs": [],
"unmapped_functions": [],
"traceability": None,
}
via = {**base, "covered_via": [{"req_id": "REQ-A", "via": "lib:REQ-L-1", "how": "implemented"}]}
assert "REQ-A via lib:REQ-L-1 (implemented)" in format_coverage_text(via)
assert "- REQ-A via lib:REQ-L-1 (implemented)" in format_coverage_markdown(via)
assert "via" not in format_coverage_text(base) and "via" not in format_coverage_markdown(base)1 more lines, not shown