test_guard_legacy_config.py¶
tests/guard/test_guard_legacy_config.py
A repo still carrying `.doxygen-guard.yaml` is told so, rather than silently defaulted.
test_a_legacy_config_with_no_guard_section_is_refused
test_guard_legacy_config.test_a_legacy_config_with_no_guard_section_is_refused(tmp_path, monkeypatch)
No `guard:` section and the old file present: refused, naming the file and `guard:`.
tests/guard/test_guard_legacy_config.py:33
Checks
assert LEGACY_CONFIG_NAME in refused.value.details() and "guard:" in refused.value.details()
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_legacy_config_with_no_guard_section_is_refused → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_a_legacy_config_with_no_guard_section_is_refused → load_config → apply_opt_in_languages |
Source · 12 lines
def test_a_legacy_config_with_no_guard_section_is_refused(tmp_path, monkeypatch):
"""@brief No `guard:` section and the old file present: refused, naming the file and `guard:`."""
(tmp_path / LEGACY_CONFIG_NAME).write_text("validate:\n presence:\n require_brief: true\n")
## FIXTURE CHANGED (2.0.0, R5-CFG F1): `thread_patterns: [worker]` was never read (a list
## under a mapping section) and is now refused; these tests only need a non-gate section.
(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")
monkeypatch.chdir(tmp_path)
with pytest.raises(ConfigError) as refused:
load_config()
assert LEGACY_CONFIG_NAME in refused.value.details() and "guard:" in refused.value.details()
Activity · 6 steps
test_a_migrated_repo_with_the_leftover_is_refused_too
test_guard_legacy_config.test_a_migrated_repo_with_the_leftover_is_refused_too(tmp_path, monkeypatch)
A `guard:` section does not excuse the leftover.
tests/guard/test_guard_legacy_config.py:45
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_migrated_repo_with_the_leftover_is_refused_too → load_config |
| REQ-DDB-GUARD-014 | measured | |
| REQ-DDB-GUARD-024 | inferred | test_a_migrated_repo_with_the_leftover_is_refused_too → load_config → apply_opt_in_languages |
Source · 14 lines
def test_a_migrated_repo_with_the_leftover_is_refused_too(tmp_path, monkeypatch):
"""1.1.0 deliberately did NOT warn here ("not nagged on every commit"). 2.0.0 reverses it: a
leftover beside a migrated `guard:` section is still a file a contributor reads and believes,
and a refusal cannot be learned-to-ignore the way a repeated warning can — it is deleted once.
@brief A `guard:` section does not excuse the leftover. @version 2
"""
(tmp_path / LEGACY_CONFIG_NAME).write_text("validate: {}\n")
(tmp_path / ".clew.yaml").write_text("guard:\n validate:\n exclude: []\n")
monkeypatch.chdir(tmp_path)
with pytest.raises(ConfigError):
load_config()
Activity · 5 steps
test_no_legacy_file_means_no_warning
test_guard_legacy_config.test_no_legacy_file_means_no_warning(tmp_path, monkeypatch, caplog)
A repo that never used doxygen-guard sees nothing.
tests/guard/test_guard_legacy_config.py:59
Checks
assert not [r for r in caplog.records if r.levelno >= logging.WARNING]
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_no_legacy_file_means_no_warning → load_config |
| REQ-DDB-GUARD-024 | inferred | test_no_legacy_file_means_no_warning → load_config → apply_opt_in_languages |
Source · 11 lines
def test_no_legacy_file_means_no_warning(tmp_path, monkeypatch, caplog):
"""@brief A repo that never used doxygen-guard sees nothing. @version 1"""
(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")
monkeypatch.chdir(tmp_path)
with caplog.at_level(logging.WARNING, logger="clew.guard.config"):
load_config()
assert not [r for r in caplog.records if r.levelno >= logging.WARNING]
Activity · 5 steps
test_the_index_warns_too
test_guard_legacy_config.test_the_index_warns_too(tmp_path, caplog)
`load_declaration` names the legacy file too.
tests/guard/test_guard_legacy_config.py:70
Checks
assert LEGACY_CONFIG_NAME in " ".join(r.getMessage() for r in caplog.records)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-CONFIG-001 | measured | test_the_index_warns_too → load_declaration |
| REQ-DDB-GUARD-012 | inferred | test_the_index_warns_too → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node |
| REQ-DDB-WIKI-054 | inferred | test_the_index_warns_too → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_list_section → all |
Source · 22 lines
def test_the_index_warns_too(tmp_path, caplog):
"""BOTH SIDES, because the index reads the gate's config as well: the `@req` id pattern
and the requirements catalog come from `guard:`, so a repository with an inert legacy file
has its requirement LINKS defaulted in the graph for the same reason its gate stopped
enforcing them. An owner who only ever runs `clew index` would otherwise never see the
warning at all.
The gate's own helper is reused rather than copied — `clew/declaration.py` already imports
the gate's config module for the section name — so the two sides cannot describe the
migration differently.
@brief `load_declaration` names the legacy file too. @version 1
"""
from clew.declaration import load_declaration
(tmp_path / LEGACY_CONFIG_NAME).write_text("validate: {}\n")
(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")
with caplog.at_level(logging.WARNING):
load_declaration(tmp_path)
assert LEGACY_CONFIG_NAME in " ".join(r.getMessage() for r in caplog.records)1 more lines, not shown