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.
Checks
assert any("wiki.check.ears" in p for p in problems), problems
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_a_non_boolean_ears_is_refused_by_name → _config → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-042 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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
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.
Checks
assert ears_pattern(statement) is None
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-042 | measured | test_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
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.
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_check_notes_name_each_requirement_in_no_pattern → ears_notes → connect |
| REQ-DDB-WIKI-042 | measured | test_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
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.
Checks
assert ears_pattern(statement) == pattern
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-042 | measured | test_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.
Checks
assert config.ears is False and problems == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_ears_is_off_unless_declared → _config → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-042 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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
test_wiki_check_ears_turns_it_on
None test_wiki_ears.test_wiki_check_ears_turns_it_on(tmp_path)
`wiki.check.ears: true`.
Checks
assert config.ears is True and problems == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_wiki_check_ears_turns_it_on → _config → load_wiki_config → _requirements_section → read_requirements_section |
| REQ-DDB-WIKI-042 | catalog | |
| REQ-DDB-WIKI-054 | inferred | test_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 == []