test_wiki_ears.py

tests/test_wiki_ears.py

EARS pattern badge: opt-in, never a gate (S9; owner-approved 2026-11-17).

test_a_non_boolean_ears_is_refused_by_name

None test_wiki_ears.test_a_non_boolean_ears_is_refused_by_name(tmp_path)

`ears: "yes"` is a problem naming the key.

tests/test_wiki_ears.py:65

Show on the map →

Called by none

Calls _config

Checks

  • assert any("wiki.check.ears" in p for p in problems), problems

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_a_non_boolean_ears_is_refused_by_name → _config → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-042catalog
REQ-DDB-WIKI-054inferredtest_a_non_boolean_ears_is_refused_by_name → _config → load_wiki_config → _comments → all
Source · 6 lines
def test_a_non_boolean_ears_is_refused_by_name(tmp_path) -> None:
    """@brief `ears: "yes"` is a problem naming the key."""
    _config_, problems = _config(tmp_path, "wiki:\n  check: {ears: 'yes'}\n")
    assert any("wiki.check.ears" in p for p in problems), problems

Activity · 2 steps
lines 67–67_config_, problems = _config(tmp_path, "wiki:\n check: {ears: 'yes'}\n")lines 68–68assert any("wiki.check.ears" in p for p in problems), problems

test_a_statement_in_no_pattern_is_none

None test_wiki_ears.test_a_statement_in_no_pattern_is_none(str statement)

No shall clause, or an `If` without its `then`: None.

tests/test_wiki_ears.py:40

Checks

  • assert ears_pattern(statement) is None

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-042measuredtest_a_statement_in_no_pattern_is_none → ears_pattern
Source · 5 lines
def test_a_statement_in_no_pattern_is_none(statement: str) -> None:
    """@brief No shall clause, or an `If` without its `then`: None."""
    assert ears_pattern(statement) is None

Activity · 1 steps
lines 42–42assert ears_pattern(statement) is None

test_check_notes_name_each_requirement_in_no_pattern

None test_wiki_ears.test_check_notes_name_each_requirement_in_no_pattern(tmp_path)

Notes come from the index's requirements table, full statement included.

tests/test_wiki_ears.py:71

Show on the map →

Called by none

Calls ears_notes

Checks

  • assert ears_notes(db, True) == ["note: REQ-B-1 is in no EARS pattern: 'Load the data'"]
  • assert ears_notes(db, False) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-QUERY-001measuredtest_check_notes_name_each_requirement_in_no_pattern → ears_notes → connect
REQ-DDB-WIKI-042measuredtest_check_notes_name_each_requirement_in_no_pattern → ears_notes
Source · 17 lines
def test_check_notes_name_each_requirement_in_no_pattern(tmp_path) -> None:
    """@brief Notes come from the index's requirements table, full statement included."""
    import sqlite3

    from clew.wiki.ears import ears_notes

    db = tmp_path / "clew.db"
    conn = sqlite3.connect(db)
    conn.execute("CREATE TABLE requirements (id TEXT, acceptance TEXT, title TEXT)")
    conn.executemany(
        "INSERT INTO requirements VALUES (?, ?, ?)",
        [("REQ-A-1", "The loader shall parse once.", "Load"), ("REQ-B-1", "", "Load the data")],
    )
    conn.commit()
    conn.close()
    assert ears_notes(db, True) == ["note: REQ-B-1 is in no EARS pattern: 'Load the data'"]
    assert ears_notes(db, False) == []

1 more lines, not shown

Activity · 10 steps
lines 73–73import sqlite3lines 75–75from clew.wiki.ears import ears_noteslines 77–77db = tmp_path / "clew.db"lines 78–78conn = sqlite3.connect(db)lines 79–79conn.execute("CREATE TABLE requirements (id TEXT, acceptance TEXT, title TEXT)")lines 80–83conn.executemany( "INSERT INTO requirements VALUES (?, ?, ?)", [("REQ-A-1", "The loader shall parse once.", "Load"), ("REQ-B-1", "", "Load the data")], )lines 84–84conn.commit()lines 85–85conn.close()lines 86–86assert ears_notes(db, True) == ["note: REQ-B-1 is in no EARS pattern: 'Load the data'"]lines 87–87assert ears_notes(db, False) == []

test_each_ears_pattern_is_recognised

None test_wiki_ears.test_each_ears_pattern_is_recognised(str statement, str pattern)

The five patterns and their combination.

tests/test_wiki_ears.py:26

Checks

  • assert ears_pattern(statement) == pattern

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-042measuredtest_each_ears_pattern_is_recognised → ears_pattern
Source · 14 lines
def test_each_ears_pattern_is_recognised(statement: str, pattern: str) -> None:
    """@brief The five patterns and their combination."""
    assert ears_pattern(statement) == pattern


@pytest.mark.parametrize(
    "statement",
    [
        "Load the data",
        "Every item is parsed once, then the load finishes.",
        "If the index is stale, the server shall say so.",
        "",
    ],
)

test_ears_is_off_unless_declared

None test_wiki_ears.test_ears_is_off_unless_declared(tmp_path)

Default: off.

tests/test_wiki_ears.py:53

Show on the map →

Called by none

Calls _config

Checks

  • assert config.ears is False and problems == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_ears_is_off_unless_declared → _config → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-042catalog
REQ-DDB-WIKI-054inferredtest_ears_is_off_unless_declared → _config → load_wiki_config → _comments → all
Source · 6 lines
def test_ears_is_off_unless_declared(tmp_path) -> None:
    """@brief Default: off."""
    config, problems = _config(tmp_path, "wiki:\n  title: T\n")
    assert config.ears is False and problems == []

Activity · 2 steps
lines 55–55config, problems = _config(tmp_path, "wiki:\n title: T\n")lines 56–56assert config.ears is False and problems == []

test_wiki_check_ears_turns_it_on

None test_wiki_ears.test_wiki_check_ears_turns_it_on(tmp_path)

`wiki.check.ears: true`.

tests/test_wiki_ears.py:59

Show on the map →

Called by none

Calls _config

Checks

  • assert config.ears is True and problems == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-GUARD-012measuredtest_wiki_check_ears_turns_it_on → _config → load_wiki_config → _requirements_section → read_requirements_section
REQ-DDB-WIKI-042catalog
REQ-DDB-WIKI-054inferredtest_wiki_check_ears_turns_it_on → _config → load_wiki_config → _comments → all
Source · 6 lines
def test_wiki_check_ears_turns_it_on(tmp_path) -> None:
    """@brief `wiki.check.ears: true`."""
    config, problems = _config(tmp_path, "wiki:\n  check: {ears: true}\n")
    assert config.ears is True and problems == []

Activity · 2 steps
lines 61–61config, problems = _config(tmp_path, "wiki:\n check: {ears: true}\n")lines 62–62assert config.ears is True and problems == []