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

Show on the map →

Called by none

Calls load_config

Checks

  • assert LEGACY_CONFIG_NAME in refused.value.details() and "guard:" in refused.value.details()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_a_legacy_config_with_no_guard_section_is_refused → load_config
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024inferredtest_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
lines 35–35(tmp_path / LEGACY_CONFIG_NAME).write_text("validate:\n presence:\n require_brief: true\n")lines 38–38(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")lines 39–39monkeypatch.chdir(tmp_path)lines 40–40with pytest.raises(ConfigError) as refusedlines 41–41load_config()lines 42–42assert LEGACY_CONFIG_NAME in refused.value.details() and "guard:" in refused.value.details()

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

Show on the map →

Called by none

Calls load_config

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_a_migrated_repo_with_the_leftover_is_refused_too → load_config
REQ-DDB-GUARD-014measured
REQ-DDB-GUARD-024inferredtest_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
lines 52–52(tmp_path / LEGACY_CONFIG_NAME).write_text("validate: {}\n")lines 53–53(tmp_path / ".clew.yaml").write_text("guard:\n validate:\n exclude: []\n")lines 54–54monkeypatch.chdir(tmp_path)lines 55–55with pytest.raises(ConfigError)lines 56–56load_config()

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

Show on the map →

Called by none

Calls load_config

Checks

  • assert not [r for r in caplog.records if r.levelno >= logging.WARNING]

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_no_legacy_file_means_no_warning → load_config
REQ-DDB-GUARD-024inferredtest_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
lines 61–61(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")lines 62–62monkeypatch.chdir(tmp_path)lines 64–64with caplog.at_level(logging.WARNING, logger="clew.guard.config")lines 65–65load_config()lines 67–67assert not [r for r in caplog.records if r.levelno >= logging.WARNING]

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

requirementlinkedpath to the implementer
REQ-DDB-CONFIG-001measuredtest_the_index_warns_too → load_declaration
REQ-DDB-GUARD-012inferredtest_the_index_warns_too → load_declaration → load_declaration_located → _checked_sections → _checked_section → _checked_requirements → _validate_node
REQ-DDB-WIKI-054inferredtest_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

Activity · 6 steps
lines 83–83from clew.declaration import load_declarationlines 85–85(tmp_path / LEGACY_CONFIG_NAME).write_text("validate: {}\n")lines 86–86(tmp_path / ".clew.yaml").write_text("thread_patterns:\n spawns:\n - {name: worker}\n")lines 88–88with caplog.at_level(logging.WARNING)lines 89–89load_declaration(tmp_path)lines 91–91assert LEGACY_CONFIG_NAME in " ".join(r.getMessage() for r in caplog.records)