test_guard_impact.py¶
tests/guard/test_guard_impact.py
Tests for clew.guard.impact (absorbed from doxygen-guard).
test_a_range_with_no_files_reads_the_files_the_range_changed
test_guard_impact.TestRunImpact.test_a_range_with_no_files_reads_the_files_the_range_changed(self, tmp_path)
ROUND 4, R11 (found building clew's own wiki): `impact --range A..B` with no file list wrote an EMPTY report — "nothing changed" for 64 commits — because only the files named on the command line were read. A range (or --staged) with no files means every file that range changed; an empty report must mean nothing changed, never that nobody looked.
tests/guard/test_guard_impact.py:380
Checks
assert "REQ-0252" in result and "Func" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → get_changed_files → run_git → git_argv |
| REQ-DDB-GUARD-008 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions |
| REQ-DDB-GUARD-009 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → build_report → load_requirements |
| REQ-DDB-GUARD-010 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact |
| REQ-DDB-GUARD-011 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → build_report → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-013 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-016 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → build_report → load_requirements → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_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_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_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-023 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → get_changed_files |
| REQ-DDB-GUARD-024 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | measured | test_a_range_with_no_files_reads_the_files_the_range_changed → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-MCP-001 | measured |
Source · 30 lines
def test_a_range_with_no_files_reads_the_files_the_range_changed(self, tmp_path):
"""ROUND 4, R11 (found building clew's own wiki): `impact --range A..B` with no file list
wrote an EMPTY report — "nothing changed" for 64 commits — because only the files named
on the command line were read. A range (or --staged) with no files means every file that
range changed; an empty report must mean nothing changed, never that nobody looked.
"""
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Func.
* @version 1.0
* @req REQ-0252
*/
void Func(void) {
impl();
}
""")
)
def mock_runner(cmd):
if "--name-only" in cmd:
return f"{c_file}\n"
return "@@ -6,1 +6,1 @@\n-old\n+new\n"
config = _make_impact_config(req_file=FIXTURES_DIR / "impact" / "req.csv")
result = run_impact([], config, diff_range="A..B", run_command=mock_runner)
assert "REQ-0252" in result and "Func" in result
Activity · 6 steps
test_a_requirement_name_cannot_forge_table_rows
test_guard_impact.TestMarkdownCellEscaping.test_a_requirement_name_cannot_forge_table_rows(self)
The names come from the TARGET'S requirements catalog, and the rendered table is written to `docs/generated/impact/impact.md`, `git add`ed, and printed to stderr — where it lands in the agent's context. A name carrying `|` forges columns; one carrying a newline forges ROWS, so a catalog can write arbitrary content into a file the developer is about to commit and into the transcript of whatever is watching the commit.
tests/guard/test_guard_impact.py:593
Checks
assert len(rows) == 3, f"repo text forged table rows: {rows}"assert "FORGED" in report, ("the text must still be REPORTED — this is escaping, not filtering" )assert "\n| FORGED" not in report
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_a_requirement_name_cannot_forge_table_rows → format_markdown |
Source · 34 lines
def test_a_requirement_name_cannot_forge_table_rows(self):
"""The names come from the TARGET'S requirements catalog, and the rendered table is
written to `docs/generated/impact/impact.md`, `git add`ed, and printed to stderr —
where it lands in the agent's context. A name carrying `|` forges columns; one
carrying a newline forges ROWS, so a catalog can write arbitrary content into a file
the developer is about to commit and into the transcript of whatever is watching the
commit.
A local `_cell` collapses CR/LF/tab and escapes `|`. `_inlineable` from the pipeline
is deliberately not reused: `clew.guard` shares no code with the pipeline, and that
separation is load-bearing for the gate's startup cost.
"""
from clew.guard.impact import ChangedFunction, ImpactEntry, format_markdown
entry = ImpactEntry(
req_id="REQ-001",
req_name="Name | with pipes\n| FORGED | ROW | here |\nand more",
functions=[
ChangedFunction(
name="fn\n| SECOND | FORGED | ROW |", file_path="a.c", new_version="1.0"
)
],
)
report = format_markdown([entry])
rows = [line for line in report.splitlines() if line.startswith("|")]
## HEADER, SEPARATOR, AND EXACTLY ONE DATA ROW. Counting rows is the assertion that
## holds whatever escaping scheme is chosen, which is why it is the one asserted.
assert len(rows) == 3, f"repo text forged table rows: {rows}"
assert "FORGED" in report, (
"the text must still be REPORTED — this is escaping, not filtering"
)
assert "\n| FORGED" not in report1 more lines, not shown
Activity · 7 steps
test_all_rows_declaring_the_field_filters_normally
test_guard_impact.TestVersionFieldMustExist.test_all_rows_declaring_the_field_filters_normally(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:571
Called by none
Calls _catalog, _config, _config, filter_requirements_by_version, load_requirements_full
Checks
assert set(active) == {"REQ-VAL-001"}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_all_rows_declaring_the_field_filters_normally → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | measured | test_all_rows_declaring_the_field_filters_normally → load_requirements_full |
| REQ-DDB-GUARD-014 | measured | test_all_rows_declaring_the_field_filters_normally → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | measured | test_all_rows_declaring_the_field_filters_normally → filter_requirements_by_version → _summarise_id |
Source · 19 lines
def test_all_rows_declaring_the_field_filters_normally(self, tmp_path, monkeypatch):
catalog = self._catalog(
tmp_path,
"""\
requirements:
REQ-VAL-001:
name: Active
min_version: v0.1.0
REQ-VAL-002:
name: Future
min_version: v9.0.0
""",
)
monkeypatch.chdir(tmp_path)
config = self._config(catalog, "min_version")
active = filter_requirements_by_version(load_requirements_full(config), config)
assert set(active) == {"REQ-VAL-001"}
Activity · 5 steps
test_csv_missing_id_column_names_the_problem
test_guard_impact.TestCatalogFailuresAreUniform.test_csv_missing_id_column_names_the_problem(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:497
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_csv_missing_id_column_names_the_problem → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_csv_missing_id_column_names_the_problem → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_csv_missing_id_column_names_the_problem → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 7 lines
def test_csv_missing_id_column_names_the_problem(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.csv"
catalog.write_text("Wrong Header,name\nREQ-VAL-001,ok\n")
monkeypatch.chdir(tmp_path)
with pytest.raises(RequirementsError, match="is not in the header"):
load_requirements(self._config(catalog, "csv", id_column="Req ID"))
Activity · 5 steps
test_csv_short_row_does_not_crash
test_guard_impact.TestCatalogFailuresAreUniform.test_csv_short_row_does_not_crash(self, tmp_path, monkeypatch)
A row shorter than the header yields None values via csv restval.
tests/guard/test_guard_impact.py:504
Checks
assert reqs == {"REQ-VAL-001": "ok"}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_csv_short_row_does_not_crash → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_csv_short_row_does_not_crash → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_csv_short_row_does_not_crash → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 9 lines
def test_csv_short_row_does_not_crash(self, tmp_path, monkeypatch):
"""A row shorter than the header yields None values via csv restval."""
catalog = tmp_path / "reqs.csv"
catalog.write_text("Req ID,name,extra\nREQ-VAL-001,ok\n")
monkeypatch.chdir(tmp_path)
reqs = load_requirements(self._config(catalog, "csv", id_column="Req ID"))
assert reqs == {"REQ-VAL-001": "ok"}
Activity · 5 steps
test_current_reqs_kept
test_guard_impact.TestFilterRequirementsByVersion.test_current_reqs_kept(self)
tests/guard/test_guard_impact.py:433
Checks
assert "REQ-001" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_current_reqs_kept → filter_requirements_by_version |
| REQ-DDB-GUARD-014 | measured | test_current_reqs_kept → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_current_reqs_kept → filter_requirements_by_version → _summarise_id |
Source · 14 lines
def test_current_reqs_kept(self):
reqs = {"REQ-001": {"Min Version": "v0.5.0"}}
config = deep_merge(
CONFIG_DEFAULTS,
{
## FIXTURE CHANGED (2.0.0, R5-CFG F14): current_version is a validate scalar and
## version_field a catalog field.
"validate": {"current_version": "v1.0.0"},
"requirements": {"version_field": "Min Version"},
},
)
result = filter_requirements_by_version(reqs, config)
assert "REQ-001" in result
Activity · 4 steps
test_declared_without_file_raises
test_guard_impact.TestLoadRequirements.test_declared_without_file_raises(self)
tests/guard/test_guard_impact.py:200
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_declared_without_file_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_declared_without_file_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | inferred | test_declared_without_file_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 5 lines
def test_declared_without_file_raises(self):
config = deep_merge(CONFIG_DEFAULTS, {"requirements": {"format": "csv"}})
with pytest.raises(RequirementsError, match="impact.requirements.file"):
load_requirements(config)
Activity · 3 steps
test_empty_report
test_guard_impact.TestFormatMarkdown.test_empty_report(self)
tests/guard/test_guard_impact.py:309
Checks
assert "No requirements affected" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_empty_report → format_markdown |
Source · 5 lines
def test_empty_report(self):
result = format_markdown([])
assert "No requirements affected" in result
Activity · 2 steps
test_guard_impact.TestFormatText.test_empty_report(self)
tests/guard/test_guard_impact.py:344
Checks
assert "No requirements affected" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_empty_report → format_text |
Source · 5 lines
def test_empty_report(self):
result = format_text([])
assert "No requirements affected" in result
Activity · 2 steps
test_equal_version_kept
test_guard_impact.TestFilterRequirementsByVersion.test_equal_version_kept(self)
tests/guard/test_guard_impact.py:447
Checks
assert "REQ-001" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_equal_version_kept → filter_requirements_by_version |
| REQ-DDB-GUARD-014 | measured | test_equal_version_kept → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_equal_version_kept → filter_requirements_by_version → _summarise_id |
Source · 15 lines
def test_equal_version_kept(self):
reqs = {"REQ-001": {"Min Version": "v1.0.0"}}
config = deep_merge(
CONFIG_DEFAULTS,
{
## FIXTURE CHANGED (2.0.0, R5-CFG F14): current_version is a validate scalar and
## version_field a catalog field.
"validate": {"current_version": "v1.0.0"},
"requirements": {"version_field": "Min Version"},
},
)
result = filter_requirements_by_version(reqs, config)
assert "REQ-001" in result
Activity · 4 steps
test_finds_changed_function
test_guard_impact.TestCollectChangedFunctions.test_finds_changed_function(self, tmp_path)
tests/guard/test_guard_impact.py:48
Checks
assert len(result) == 1assert result[0].name == "Do_Stuff"assert "REQ-0252" in result[0].reqsassert result[0].new_version == "1.1"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _collect_changed_lines → _get_file_diff → get_staged_diff → run_git → git_argv |
| REQ-DDB-GUARD-008 | measured | test_finds_changed_function → collect_changed_functions |
| REQ-DDB-GUARD-010 | measured | test_finds_changed_function → collect_changed_functions → collect_changes |
| REQ-DDB-GUARD-013 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-018 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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-023 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _collect_changed_lines → parse_changed_lines |
| REQ-DDB-GUARD-024 | inferred | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | measured | test_finds_changed_function → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
Source · 29 lines
def test_finds_changed_function(self, tmp_path):
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Do stuff.
* @version 1.1
* @req REQ-0252
*/
void Do_Stuff(void) {
new_impl();
}
""")
)
def mock_runner(cmd):
return "@@ -6,1 +6,1 @@\n-old\n+new\n"
result = collect_changed_functions(
[str(c_file)],
CONFIG_DEFAULTS,
staged=True,
run_command=mock_runner,
)
assert len(result) == 1
assert result[0].name == "Do_Stuff"
assert "REQ-0252" in result[0].reqs
assert result[0].new_version == "1.1"
Activity · 8 steps
test_full_pipeline
test_guard_impact.TestRunImpact.test_full_pipeline(self, tmp_path)
tests/guard/test_guard_impact.py:352
Checks
assert "REQ-0252" in resultassert "Func" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_full_pipeline → run_impact → impact_report → get_changed_files → run_git → git_argv |
| REQ-DDB-GUARD-008 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions |
| REQ-DDB-GUARD-009 | measured | test_full_pipeline → run_impact → impact_report → build_report → load_requirements |
| REQ-DDB-GUARD-010 | measured | test_full_pipeline → run_impact |
| REQ-DDB-GUARD-011 | measured | test_full_pipeline → run_impact → impact_report → build_report → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-013 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-016 | measured | test_full_pipeline → run_impact → impact_report → build_report → load_requirements → _get_requirements_config → resolve_contained_path |
| REQ-DDB-GUARD-018 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file |
| REQ-DDB-GUARD-019 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_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_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_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-023 | measured | test_full_pipeline → run_impact → impact_report → get_changed_files |
| REQ-DDB-GUARD-024 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | measured | test_full_pipeline → run_impact → impact_report → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-INDEX-007 | measured | |
| REQ-DDB-MCP-001 | measured |
Source · 28 lines
def test_full_pipeline(self, tmp_path):
c_file = tmp_path / "test.c"
c_file.write_text(
dedent("""\
/**
* @brief Func.
* @version 1.0
* @req REQ-0252
*/
void Func(void) {
impl();
}
""")
)
def mock_runner(cmd):
return "@@ -6,1 +6,1 @@\n-old\n+new\n"
config = _make_impact_config(req_file=FIXTURES_DIR / "impact" / "req.csv")
result = run_impact(
[str(c_file)],
config,
staged=True,
run_command=mock_runner,
)
assert "REQ-0252" in result
assert "Func" in result
Activity · 7 steps
test_future_reqs_filtered
test_guard_impact.TestFilterRequirementsByVersion.test_future_reqs_filtered(self)
tests/guard/test_guard_impact.py:418
Checks
assert "REQ-001" in resultassert "REQ-002" not in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_future_reqs_filtered → filter_requirements_by_version |
| REQ-DDB-GUARD-014 | measured | test_future_reqs_filtered → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_future_reqs_filtered → filter_requirements_by_version → _summarise_id |
Source · 15 lines
def test_future_reqs_filtered(self):
reqs = {"REQ-001": {"Min Version": "v0.1.0"}, "REQ-002": {"Min Version": "v2.0.0"}}
config = deep_merge(
CONFIG_DEFAULTS,
{
## FIXTURE CHANGED (2.0.0, R5-CFG F14): current_version is a validate scalar and
## version_field a catalog field.
"validate": {"current_version": "v1.0.0"},
"requirements": {"version_field": "Min Version"},
},
)
result = filter_requirements_by_version(reqs, config)
assert "REQ-001" in result
assert "REQ-002" not in result
Activity · 5 steps
test_groups_by_requirement
test_guard_impact.TestBuildImpactReport.test_groups_by_requirement(self)
tests/guard/test_guard_impact.py:273
Checks
assert len(entries) == 2assert len(req252.functions) == 2assert req252.req_name == "BLE-First Pairing"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_groups_by_requirement → build_impact_report → build_report → load_requirements |
| REQ-DDB-GUARD-010 | measured | test_groups_by_requirement → build_impact_report |
| REQ-DDB-GUARD-011 | measured | test_groups_by_requirement → build_impact_report → build_report → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_groups_by_requirement → build_impact_report → build_report → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 14 lines
def test_groups_by_requirement(self):
config = _make_impact_config(req_file=FIXTURES_DIR / "impact" / "req.csv")
changed = [
ChangedFunction(name="FuncA", file_path="a.c", reqs=["REQ-0252"]),
ChangedFunction(name="FuncB", file_path="b.c", reqs=["REQ-0252"]),
ChangedFunction(name="FuncC", file_path="c.c", reqs=["REQ-0555"]),
]
entries = build_impact_report(changed, config)
assert len(entries) == 2
req252 = next(e for e in entries if e.req_id == "REQ-0252")
assert len(req252.functions) == 2
assert req252.req_name == "BLE-First Pairing"
Activity · 7 steps
test_id_failing_configured_pattern_raises
test_guard_impact.TestLoadRequirements.test_id_failing_configured_pattern_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:255
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_id_failing_configured_pattern_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_id_failing_configured_pattern_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_id_failing_configured_pattern_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 15 lines
def test_id_failing_configured_pattern_raises(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.yaml"
monkeypatch.chdir(tmp_path)
catalog.write_text("requirements:\n REQ-0001:\n name: Legacy\n")
config = deep_merge(
CONFIG_DEFAULTS,
{
"validate": {"tags": {"req": {"pattern": r"^REQ-[A-Z]+-[0-9]{3}$"}}},
"requirements": {"file": catalog.name, "format": "yaml"},
},
)
with pytest.raises(RequirementsError, match="does not match"):
load_requirements(config)
Activity · 6 steps
test_json_list_with_non_dict_element_does_not_crash
test_guard_impact.TestCatalogFailuresAreUniform.test_json_list_with_non_dict_element_does_not_crash(self, tmp_path, monkeypatch)
The JSON path lacked the isinstance guard its YAML twin had.
tests/guard/test_guard_impact.py:489
Checks
assert reqs == {"REQ-VAL-001": "ok"}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_json_list_with_non_dict_element_does_not_crash → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_json_list_with_non_dict_element_does_not_crash → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_json_list_with_non_dict_element_does_not_crash → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 8 lines
def test_json_list_with_non_dict_element_does_not_crash(self, tmp_path, monkeypatch):
"""The JSON path lacked the isinstance guard its YAML twin had."""
catalog = tmp_path / "reqs.json"
catalog.write_text('["bare string", {"Req ID": "REQ-VAL-001", "name": "ok"}]')
monkeypatch.chdir(tmp_path)
reqs = load_requirements(self._config(catalog, "json", id_column="Req ID"))
assert reqs == {"REQ-VAL-001": "ok"}
Activity · 5 steps
test_json_object_instead_of_list_raises
test_guard_impact.TestCatalogFailuresAreUniform.test_json_object_instead_of_list_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:482
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_json_object_instead_of_list_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_json_object_instead_of_list_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_json_object_instead_of_list_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 7 lines
def test_json_object_instead_of_list_raises(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.json"
catalog.write_text('{"REQ-VAL-001": {"name": "x"}}')
monkeypatch.chdir(tmp_path)
with pytest.raises(RequirementsError, match="list of rows"):
load_requirements(self._config(catalog, "json"))
Activity · 5 steps
test_lists_reqs
test_guard_impact.TestFormatText.test_lists_reqs(self)
tests/guard/test_guard_impact.py:335
Checks
assert "REQ-0252" in resultassert "REQ-0555" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_lists_reqs → format_text |
Source · 9 lines
def test_lists_reqs(self):
entries = [
ImpactEntry(req_id="REQ-0252"),
ImpactEntry(req_id="REQ-0555"),
]
result = format_text(entries)
assert "REQ-0252" in result
assert "REQ-0555" in result
Activity · 4 steps
test_load_csv
test_guard_impact.TestLoadRequirements.test_load_csv(self)
tests/guard/test_guard_impact.py:111
Checks
assert reqs["REQ-0252"] == "BLE-First Pairing"assert reqs["REQ-0555"] == "OTA Download"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_load_csv → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_load_csv → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_load_csv → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 6 lines
def test_load_csv(self):
config = _make_impact_config(req_file=FIXTURES_DIR / "impact" / "req.csv")
reqs = load_requirements(config)
assert reqs["REQ-0252"] == "BLE-First Pairing"
assert reqs["REQ-0555"] == "OTA Download"
Activity · 4 steps
test_load_json
test_guard_impact.TestLoadRequirements.test_load_json(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:117
Checks
assert reqs["REQ-0001"] == "Test Req"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_load_json → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_load_json → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_load_json → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 24 lines
def test_load_json(self, tmp_path, monkeypatch):
req_file = tmp_path / "req.json"
monkeypatch.chdir(tmp_path)
req_file.write_text(
json.dumps(
[
{"Req ID": "REQ-0001", "Requirement Name": "Test Req"},
]
)
)
config = deep_merge(
CONFIG_DEFAULTS,
{
"requirements": {
"file": req_file.name,
"id_column": "Req ID",
"name_column": "Requirement Name",
"format": "json",
},
},
)
reqs = load_requirements(config)
assert reqs["REQ-0001"] == "Test Req"
Activity · 6 steps
test_load_yaml
test_guard_impact.TestLoadRequirements.test_load_yaml(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:141
Checks
assert reqs["REQ-0001"] == "YAML Req"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_load_yaml → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_load_yaml → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_load_yaml → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 23 lines
def test_load_yaml(self, tmp_path, monkeypatch):
req_file = tmp_path / "req.yaml"
monkeypatch.chdir(tmp_path)
req_file.write_text(
dedent("""\
- Req ID: REQ-0001
Requirement Name: YAML Req
""")
)
config = deep_merge(
CONFIG_DEFAULTS,
{
"requirements": {
"file": req_file.name,
"id_column": "Req ID",
"name_column": "Requirement Name",
"format": "yaml",
},
},
)
reqs = load_requirements(config)
assert reqs["REQ-0001"] == "YAML Req"
Activity · 6 steps
test_malformed_json_raises_requirements_error
test_guard_impact.TestCatalogFailuresAreUniform.test_malformed_json_raises_requirements_error(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:475
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_malformed_json_raises_requirements_error → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_malformed_json_raises_requirements_error → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_malformed_json_raises_requirements_error → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 7 lines
def test_malformed_json_raises_requirements_error(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.json"
catalog.write_text("{not valid json")
monkeypatch.chdir(tmp_path)
with pytest.raises(RequirementsError, match="Could not parse"):
load_requirements(self._config(catalog, "json"))
Activity · 5 steps
test_mapping_form_loads
test_guard_impact.TestLoadRequirements.test_mapping_form_loads(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:227
Checks
assert load_requirements(config)["REQ-VAL-001"] == "Presence check"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_mapping_form_loads → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_mapping_form_loads → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | measured | test_mapping_form_loads → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 17 lines
def test_mapping_form_loads(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.yaml"
monkeypatch.chdir(tmp_path)
catalog.write_text(
dedent("""\
requirements:
REQ-VAL-001:
name: Presence check
subsystem: Validate
""")
)
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": catalog.name, "format": "yaml"}},
)
assert load_requirements(config)["REQ-VAL-001"] == "Presence check"
Activity · 5 steps
test_missing_file_raises
test_guard_impact.TestLoadRequirements.test_missing_file_raises(self)
A declared-but-absent catalog must fail loudly, not degrade to an empty dict.
tests/guard/test_guard_impact.py:168
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_missing_file_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_missing_file_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_missing_file_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 9 lines
def test_missing_file_raises(self):
"""A declared-but-absent catalog must fail loudly, not degrade to an empty dict."""
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": "nonexistent-req.csv", "format": "csv"}},
)
with pytest.raises(RequirementsError, match="not found"):
load_requirements(config)
Activity · 3 steps
test_missing_name_field_raises
test_guard_impact.TestLoadRequirements.test_missing_name_field_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:244
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_missing_name_field_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_missing_name_field_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_missing_name_field_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 11 lines
def test_missing_name_field_raises(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.yaml"
monkeypatch.chdir(tmp_path)
catalog.write_text("requirements:\n REQ-VAL-001:\n subsystem: Validate\n")
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": catalog.name, "format": "yaml"}},
)
with pytest.raises(RequirementsError, match="missing required field"):
load_requirements(config)
Activity · 6 steps
test_no_change_no_result
test_guard_impact.TestCollectChangedFunctions.test_no_change_no_result(self, tmp_path)
tests/guard/test_guard_impact.py:77
Checks
assert result == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_no_change_no_result → collect_changed_functions → collect_changes → _collect_changed_lines → _get_file_diff → get_staged_diff → run_git → git_argv |
| REQ-DDB-GUARD-008 | measured | test_no_change_no_result → collect_changed_functions |
| REQ-DDB-GUARD-010 | measured | test_no_change_no_result → collect_changed_functions → collect_changes |
| REQ-DDB-GUARD-013 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-018 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file |
| REQ-DDB-GUARD-019 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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-023 | measured | test_no_change_no_result → collect_changed_functions → collect_changes → _collect_changed_lines → parse_changed_lines |
| REQ-DDB-GUARD-024 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | inferred | test_no_change_no_result → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
Source · 15 lines
def test_no_change_no_result(self, tmp_path):
c_file = tmp_path / "test.c"
c_file.write_text("void Func(void) { x(); }")
def mock_runner(cmd):
return ""
result = collect_changed_functions(
[str(c_file)],
CONFIG_DEFAULTS,
staged=True,
run_command=mock_runner,
)
assert result == []
Activity · 5 steps
test_no_changes
test_guard_impact.TestBuildImpactReport.test_no_changes(self)
tests/guard/test_guard_impact.py:287
Checks
assert entries == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_no_changes → build_impact_report → build_report → load_requirements |
| REQ-DDB-GUARD-010 | measured | test_no_changes → build_impact_report |
| REQ-DDB-GUARD-011 | measured | test_no_changes → build_impact_report → build_report → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | inferred | test_no_changes → build_impact_report → build_report → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 5 lines
def test_no_changes(self):
entries = build_impact_report([], CONFIG_DEFAULTS)
assert entries == []
Activity · 2 steps
test_no_requirements_config
test_guard_impact.TestLoadRequirements.test_no_requirements_config(self)
tests/guard/test_guard_impact.py:164
Checks
assert reqs == {}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_no_requirements_config → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_no_requirements_config → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-016 | inferred | test_no_requirements_config → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 4 lines
def test_no_requirements_config(self):
reqs = load_requirements(CONFIG_DEFAULTS)
assert reqs == {}
Activity · 2 steps
test_no_version_gate_returns_all
test_guard_impact.TestFilterRequirementsByVersion.test_no_version_gate_returns_all(self)
tests/guard/test_guard_impact.py:413
Checks
assert result == reqs
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_no_version_gate_returns_all → filter_requirements_by_version |
| REQ-DDB-GUARD-014 | inferred | test_no_version_gate_returns_all → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | inferred | test_no_version_gate_returns_all → filter_requirements_by_version → _summarise_id |
Source · 5 lines
def test_no_version_gate_returns_all(self):
reqs = {"REQ-001": {"Min Version": "v0.1.0"}, "REQ-002": {"Min Version": "v2.0.0"}}
result = filter_requirements_by_version(reqs, CONFIG_DEFAULTS)
assert result == reqs
Activity · 3 steps
test_out_of_tree_catalog_rejected
test_guard_impact.TestLoadRequirements.test_out_of_tree_catalog_rejected(self, tmp_path)
A catalog outside the repo is refused before it is ever opened.
tests/guard/test_guard_impact.py:177
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_out_of_tree_catalog_rejected → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_out_of_tree_catalog_rejected → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_out_of_tree_catalog_rejected → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 15 lines
def test_out_of_tree_catalog_rejected(self, tmp_path):
"""A catalog outside the repo is refused before it is ever opened.
Its rows are echoed back in validation errors, so an unconstrained path made
the error channel a file-disclosure primitive.
"""
outside = tmp_path / "secret.csv"
outside.write_text("Req ID,name\nREQ-X,y\n")
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": str(outside), "format": "csv"}},
)
with pytest.raises(ConfigError, match="must stay inside the repository"):
load_requirements(config)
Activity · 5 steps
test_renders_table
test_guard_impact.TestFormatMarkdown.test_renders_table(self)
tests/guard/test_guard_impact.py:295
Checks
assert "## Change Impact Report" in resultassert "REQ-0252" in resultassert "Func" in resultassert "1 requirement(s)" in result
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_renders_table → format_markdown |
Source · 14 lines
def test_renders_table(self):
entries = [
ImpactEntry(
req_id="REQ-0252",
req_name="Pairing",
functions=[ChangedFunction(name="Func", file_path="a.c", reqs=["REQ-0252"])],
),
]
result = format_markdown(entries)
assert "## Change Impact Report" in result
assert "REQ-0252" in result
assert "Func" in result
assert "1 requirement(s)" in result
Activity · 6 steps
test_row_missing_the_field_raises
test_guard_impact.TestVersionFieldMustExist.test_row_missing_the_field_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:553
Called by none
Calls _catalog, _config, _config, filter_requirements_by_version, load_requirements_full
Checks
assert any("REQ-VAL-002" in p for p in exc.value.problems)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_row_missing_the_field_raises → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | measured | test_row_missing_the_field_raises → load_requirements_full |
| REQ-DDB-GUARD-014 | measured | test_row_missing_the_field_raises → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | measured | test_row_missing_the_field_raises → filter_requirements_by_version → _summarise_id |
Source · 18 lines
def test_row_missing_the_field_raises(self, tmp_path, monkeypatch):
catalog = self._catalog(
tmp_path,
"""\
requirements:
REQ-VAL-001:
name: Has it
min_version: v0.1.0
REQ-VAL-002:
name: Missing it
""",
)
monkeypatch.chdir(tmp_path)
config = self._config(catalog, "min_version")
with pytest.raises(RequirementsError) as exc:
filter_requirements_by_version(load_requirements_full(config), config)
assert any("REQ-VAL-002" in p for p in exc.value.problems)
Activity · 6 steps
test_traversal_catalog_rejected
test_guard_impact.TestLoadRequirements.test_traversal_catalog_rejected(self)
tests/guard/test_guard_impact.py:192
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_traversal_catalog_rejected → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_traversal_catalog_rejected → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_traversal_catalog_rejected → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 8 lines
def test_traversal_catalog_rejected(self):
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": "../../etc/passwd", "format": "csv"}},
)
with pytest.raises(ConfigError, match="must stay inside the repository"):
load_requirements(config)
Activity · 3 steps
test_typoed_version_field_raises
test_guard_impact.TestVersionFieldMustExist.test_typoed_version_field_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:538
Called by none
Calls _catalog, _config, _config, filter_requirements_by_version, load_requirements_full
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_typoed_version_field_raises → filter_requirements_by_version |
| REQ-DDB-GUARD-011 | measured | test_typoed_version_field_raises → load_requirements_full |
| REQ-DDB-GUARD-014 | measured | test_typoed_version_field_raises → filter_requirements_by_version → parse_version |
| REQ-DDB-GUARD-016 | measured | test_typoed_version_field_raises → filter_requirements_by_version → _summarise_id |
Source · 15 lines
def test_typoed_version_field_raises(self, tmp_path, monkeypatch):
catalog = self._catalog(
tmp_path,
"""\
requirements:
REQ-VAL-001:
name: A req
min_version: v0.1.0
""",
)
monkeypatch.chdir(tmp_path)
config = self._config(catalog, "min_verison") # typo
with pytest.raises(RequirementsError, match="do not declare it"):
filter_requirements_by_version(load_requirements_full(config), config)
Activity · 5 steps
test_unknown_extension_skipped
test_guard_impact.TestCollectChangedFunctions.test_unknown_extension_skipped(self, tmp_path)
tests/guard/test_guard_impact.py:92
Checks
assert result == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _collect_changed_lines → _get_file_diff → get_staged_diff → run_git → git_argv |
| REQ-DDB-CONFIG-009 | measured | |
| REQ-DDB-GUARD-001 | measured | |
| REQ-DDB-GUARD-002 | inferred | |
| REQ-DDB-GUARD-003 | inferred | |
| REQ-DDB-GUARD-004 | inferred | |
| REQ-DDB-GUARD-005 | inferred | |
| REQ-DDB-GUARD-006 | inferred | |
| REQ-DDB-GUARD-007 | inferred | |
| REQ-DDB-GUARD-008 | measured | test_unknown_extension_skipped → collect_changed_functions |
| REQ-DDB-GUARD-009 | inferred | |
| REQ-DDB-GUARD-010 | measured | test_unknown_extension_skipped → collect_changed_functions → collect_changes |
| REQ-DDB-GUARD-011 | inferred | |
| REQ-DDB-GUARD-013 | measured | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → get_language_config |
| REQ-DDB-GUARD-014 | inferred | |
| REQ-DDB-GUARD-016 | inferred | |
| REQ-DDB-GUARD-018 | measured | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file |
| REQ-DDB-GUARD-019 | inferred | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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 | inferred | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → language_for_file |
| REQ-DDB-GUARD-021 | inferred | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_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-023 | measured | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _collect_changed_lines → parse_changed_lines |
| REQ-DDB-GUARD-024 | inferred | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _is_rust_test_item |
| REQ-DDB-GUARD-025 | inferred | test_unknown_extension_skipped → collect_changed_functions → collect_changes → _extract_changed_functions → parse_source_file → parse_source_file_with_content → parse_content_for_file → parse_functions → parse_functions_ts → _collect_functions → _js_returns_void |
| REQ-DDB-GUARD-026 | inferred | |
| REQ-DDB-GUARD-027 | inferred | |
| REQ-DDB-PIPE-011 | measured | |
| REQ-DDB-WIKI-054 | inferred |
Source · 16 lines
def test_unknown_extension_skipped(self, tmp_path):
rs_file = tmp_path / "test.rs"
rs_file.write_text("fn foo() {}")
def mock_runner(cmd):
return "@@ -1,1 +1,1 @@\n-old\n+new\n"
result = collect_changed_functions(
[str(rs_file)],
CONFIG_DEFAULTS,
staged=True,
run_command=mock_runner,
)
assert result == []
Activity · 5 steps
test_unknown_format_raises
test_guard_impact.TestLoadRequirements.test_unknown_format_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:205
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_unknown_format_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_unknown_format_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_unknown_format_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 11 lines
def test_unknown_format_raises(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.toml"
monkeypatch.chdir(tmp_path)
catalog.write_text("nope\n")
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": catalog.name, "format": "toml"}},
)
with pytest.raises(RequirementsError, match="Unknown requirements format"):
load_requirements(config)
Activity · 6 steps
test_valid_json
test_guard_impact.TestFormatJson.test_valid_json(self)
tests/guard/test_guard_impact.py:317
Checks
assert len(data) == 1assert data[0]["req_id"] == "REQ-0001"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-010 | measured | test_valid_json → format_json |
Source · 15 lines
def test_valid_json(self):
entries = [
ImpactEntry(
req_id="REQ-0001",
functions=[ChangedFunction(name="F", file_path="a.c", new_version="1.0")],
),
]
result = format_json(entries)
## SPEC CHANGED (2.0.0, PS3, owner Q/A 2026-11-19): the report is an object carrying
## `schema_version`, its entries under `entries` (it was a bare array with no version).
data = json.loads(result)["entries"]
assert len(data) == 1
assert data[0]["req_id"] == "REQ-0001"
Activity · 5 steps
test_wrong_yaml_shape_raises
test_guard_impact.TestLoadRequirements.test_wrong_yaml_shape_raises(self, tmp_path, monkeypatch)
tests/guard/test_guard_impact.py:216
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-009 | measured | test_wrong_yaml_shape_raises → load_requirements |
| REQ-DDB-GUARD-011 | measured | test_wrong_yaml_shape_raises → load_requirements → _get_requirements_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-016 | measured | test_wrong_yaml_shape_raises → load_requirements → _get_requirements_config → resolve_contained_path |
Source · 11 lines
def test_wrong_yaml_shape_raises(self, tmp_path, monkeypatch):
catalog = tmp_path / "reqs.yaml"
monkeypatch.chdir(tmp_path)
catalog.write_text("just-a-string\n")
config = deep_merge(
CONFIG_DEFAULTS,
{"requirements": {"file": catalog.name, "format": "yaml"}},
)
with pytest.raises(RequirementsError, match="must be a mapping"):
load_requirements(config)