test_guard_config_index.py¶
tests/test_guard_config_index.py
The gate's config is the `guard:` section of `.clew.yaml`, read by gate and index alike.
test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate
None test_guard_config_index.test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate(Path tmp_path)
tests/test_guard_config_index.py:84
Checks
assert load_guard_config(tmp_path) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate → load_guard_config |
| REQ-DDB-GUARD-012 | measured | test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate → load_config → apply_opt_in_languages |
Source · 8 lines
def test_a_guard_section_that_is_not_a_mapping_is_refused_by_the_gate(tmp_path: Path) -> None:
path = _write(tmp_path, "guard: [validate]\n")
with pytest.raises(ConfigError):
load_config(path)
assert load_guard_config(tmp_path) is None
Activity · 4 steps
test_a_leftover_doxygen_guard_yaml_is_not_read
None test_guard_config_index.test_a_leftover_doxygen_guard_yaml_is_not_read(Path tmp_path)
HARD BREAK, pinned. A repo that has not moved its config runs on the defaults; a silent fallback to the old file would leave two configs that can disagree.
tests/test_guard_config_index.py:126
Checks
assert load_guard_config(tmp_path) is Noneassert load_declaration(tmp_path) == {}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_a_leftover_doxygen_guard_yaml_is_not_read → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_a_leftover_doxygen_guard_yaml_is_not_read → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-024 | inferred | test_a_leftover_doxygen_guard_yaml_is_not_read → load_guard_config → read_guard_config → load_config → apply_opt_in_languages |
| REQ-DDB-WIKI-054 | inferred | test_a_leftover_doxygen_guard_yaml_is_not_read → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 8 lines
def test_a_leftover_doxygen_guard_yaml_is_not_read(tmp_path: Path) -> None:
"""HARD BREAK, pinned. A repo that has not moved its config runs on the defaults; a
silent fallback to the old file would leave two configs that can disagree."""
old = _GUARD.replace("guard:\n", "").replace("\n ", "\n")
_write(tmp_path, old + "x-clew:\n index_scope:\n roots: [src]\n", ".doxygen-guard.yaml")
assert load_guard_config(tmp_path) is None
assert load_declaration(tmp_path) == {}1 more lines, not shown
Activity · 4 steps
test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate
None test_guard_config_index.test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate(Path tmp_path, caplog)
tests/test_guard_config_index.py:70
Checks
assert load_guard_config(tmp_path) is Noneassert str(path) in caplog.text and "no_such_key" in caplog.text, ("the index must say which file it could not use and why, not fall back silently" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate → load_guard_config |
| REQ-DDB-GUARD-012 | measured | test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate → load_config → apply_opt_in_languages |
Source · 14 lines
def test_an_invalid_section_degrades_the_index_and_is_refused_by_the_gate(
tmp_path: Path, caplog
) -> None:
path = _write(tmp_path, "guard:\n validate:\n no_such_key: 1\n")
with caplog.at_level(logging.WARNING):
assert load_guard_config(tmp_path) is None
assert str(path) in caplog.text and "no_such_key" in caplog.text, (
"the index must say which file it could not use and why, not fall back silently"
)
with pytest.raises(ConfigError):
load_config(path)
Activity · 6 steps
test_no_file_and_no_section_both_mean_nothing_declared
None test_guard_config_index.test_no_file_and_no_section_both_mean_nothing_declared(Path tmp_path)
tests/test_guard_config_index.py:61
Checks
assert load_guard_config(tmp_path) is Noneassert load_guard_config(tmp_path) is None, ("a .clew.yaml with no guard: section declares nothing to the gate" )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_no_file_and_no_section_both_mean_nothing_declared → load_guard_config |
| REQ-DDB-GUARD-012 | measured | test_no_file_and_no_section_both_mean_nothing_declared → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-024 | inferred | test_no_file_and_no_section_both_mean_nothing_declared → load_guard_config → read_guard_config → load_config → apply_opt_in_languages |
Source · 9 lines
def test_no_file_and_no_section_both_mean_nothing_declared(tmp_path: Path) -> None:
assert load_guard_config(tmp_path) is None
_write(tmp_path, "index_scope:\n roots: [src]\n")
assert load_guard_config(tmp_path) is None, (
"a .clew.yaml with no guard: section declares nothing to the gate"
)
Activity · 3 steps
test_the_gate_reads_the_same_section
None test_guard_config_index.test_the_gate_reads_the_same_section(Path tmp_path)
tests/test_guard_config_index.py:52
Checks
assert cfg["validate"]["tags"]["req"]["pattern"] == "^REQ-[0-9]{4}$"assert cfg["requirements"]["file"] == "catalog.yaml"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | catalog | |
| REQ-DDB-GUARD-012 | measured | test_the_gate_reads_the_same_section → load_config |
| REQ-DDB-GUARD-024 | measured | test_the_gate_reads_the_same_section → load_config → apply_opt_in_languages |
Source · 9 lines
def test_the_gate_reads_the_same_section(tmp_path: Path) -> None:
path = _write(tmp_path, _GUARD)
cfg = load_config(path)
assert cfg["validate"]["tags"]["req"]["pattern"] == "^REQ-[0-9]{4}$"
assert cfg["requirements"]["file"] == "catalog.yaml"
Activity · 4 steps
test_the_guard_section_is_known_but_is_not_an_index_declaration
None test_guard_config_index.test_the_guard_section_is_known_but_is_not_an_index_declaration(Path tmp_path)
tests/test_guard_config_index.py:92
Checks
assert load_declaration(tmp_path) == {"index_scope": {"roots": ["src"]}}assert load_declaration(tmp_path) == {}, ("a file that configures only the gate must declare nothing to the index" )assert "configures only the gate" in describe_declaration(tmp_path)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_guard_section_is_known_but_is_not_an_index_declaration → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_the_guard_section_is_known_but_is_not_an_index_declaration → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_the_guard_section_is_known_but_is_not_an_index_declaration → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 17 lines
def test_the_guard_section_is_known_but_is_not_an_index_declaration(tmp_path: Path) -> None:
## A `guard:`-ONLY file (2.0.0: `_GUARD` also carries the top-level catalog, which IS the
## repository's declaration, so this property needs a file without one).
gate_only = _GUARD.split("guard:\n", 1)[1]
gate_only = "guard:\n" + gate_only
_write(tmp_path, gate_only + "index_scope:\n roots: [src]\n")
(tmp_path / "src").mkdir()
assert load_declaration(tmp_path) == {"index_scope": {"roots": ["src"]}}
_write(tmp_path, gate_only)
assert load_declaration(tmp_path) == {}, (
"a file that configures only the gate must declare nothing to the index"
)
assert "configures only the gate" in describe_declaration(tmp_path)
Activity · 8 steps
test_the_index_reads_the_guard_section_of_clew_yaml
None test_guard_config_index.test_the_index_reads_the_guard_section_of_clew_yaml(Path tmp_path)
tests/test_guard_config_index.py:42
Checks
assert cfg is not Noneassert cfg["requirements"]["file"] == "catalog.yaml"assert resolve_req_id_pattern(cfg).pattern == "^REQ-[0-9]{4}$"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_index_reads_the_guard_section_of_clew_yaml → load_guard_config |
| REQ-DDB-GUARD-012 | measured | test_the_index_reads_the_guard_section_of_clew_yaml → load_guard_config → read_guard_config → read_requirements_section |
| REQ-DDB-GUARD-024 | measured | test_the_index_reads_the_guard_section_of_clew_yaml → load_guard_config → read_guard_config → load_config → apply_opt_in_languages |
Source · 10 lines
def test_the_index_reads_the_guard_section_of_clew_yaml(tmp_path: Path) -> None:
_write(tmp_path, _GUARD)
cfg = load_guard_config(tmp_path)
assert cfg is not None
assert cfg["requirements"]["file"] == "catalog.yaml"
assert resolve_req_id_pattern(cfg).pattern == "^REQ-[0-9]{4}$"
Activity · 5 steps
test_the_schema_contract_names_the_file_and_section
None test_guard_config_index.test_the_schema_contract_names_the_file_and_section()
tests/test_guard_config_index.py:118
Checks
assert contract["config_file"] == CONFIG_FILE_NAMEassert contract["config_section"] == CONFIG_SECTIONassert "passthrough_prefix" not in contract
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | catalog | |
| REQ-DDB-GUARD-015 | measured | test_the_schema_contract_names_the_file_and_section → build_schema_contract |
Source · 8 lines
def test_the_schema_contract_names_the_file_and_section() -> None:
contract = build_schema_contract()
assert contract["config_file"] == CONFIG_FILE_NAME
assert contract["config_section"] == CONFIG_SECTION
assert "passthrough_prefix" not in contract
Activity · 4 steps
test_the_scope_fallback_names_where_it_looked
None test_guard_config_index.test_the_scope_fallback_names_where_it_looked(Path tmp_path)
tests/test_guard_config_index.py:109
Checks
assert f"no {CONFIG_FILE_NAME} was found" in reasonassert "exists but carries no index_scope" in reason
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_scope_fallback_names_where_it_looked → derive_scope |
| REQ-DDB-GUARD-012 | measured | test_the_scope_fallback_names_where_it_looked → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_the_scope_fallback_names_where_it_looked → derive_scope → _declared_index_scope → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 9 lines
def test_the_scope_fallback_names_where_it_looked(tmp_path: Path) -> None:
reason = derive_scope(tmp_path).reason
assert f"no {CONFIG_FILE_NAME} was found" in reason
_write(tmp_path, _GUARD)
reason = derive_scope(tmp_path).reason
assert "exists but carries no index_scope" in reason