test_not_indexed_report.py¶
tests/test_not_indexed_report.py
A miss names the file types it did not read, so an empty answer is not read as absence.
test_an_index_built_before_this_release_claims_nothing
None test_not_indexed_report.test_an_index_built_before_this_release_claims_nothing(Path tmp_path)
No row means an empty report and a zero count.
tests/test_not_indexed_report.py:156
Checks
assert scope.not_indexed == ()assert scope.not_indexed_count == 0
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_an_index_built_before_this_release_claims_nothing → index_scope → connect |
| REQ-DDB-QUERY-003 | measured | test_an_index_built_before_this_release_claims_nothing → index_scope → _indexed_paths → table_exists |
| REQ-DDB-QUERY-007 | measured | test_an_index_built_before_this_release_claims_nothing → index_scope |
Source · 22 lines
def test_an_index_built_before_this_release_claims_nothing(tmp_path: Path) -> None:
"""The row is absent, which must read as "not recorded" and never as "nothing was
missed" — the same rule `IndexScope.source` follows for an index built before the
provenance was stamped.
@brief No row means an empty report and a zero count. @version 1
"""
db = tmp_path / "clew.db"
conn = sqlite3.connect(str(db))
try:
conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")
conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")
conn.commit()
finally:
conn.close()
scope = index_scope(db)
assert scope.not_indexed == ()
assert scope.not_indexed_count == 0
Activity · 9 steps
test_an_unrecorded_report_is_absent_from_the_served_payload
None test_not_indexed_report.test_an_unrecorded_report_is_absent_from_the_served_payload()
No stamped report means no key in the reply.
tests/test_not_indexed_report.py:178
Checks
assert _scope_payload(stamped)["not_indexed"] == [".sh=3", ".yml=1"]assert _scope_payload(stamped)["not_indexed_count"] == 4assert "not_indexed" not in _scope_payload(unrecorded)assert "not_indexed_count" not in _scope_payload(unrecorded)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_an_unrecorded_report_is_absent_from_the_served_payload → _scope_payload → one |
Source · 21 lines
def test_an_unrecorded_report_is_absent_from_the_served_payload() -> None:
"""THE FALSY-DROP RULE ON THE SERVED SURFACE. An index built before this release has no
row, and serving `not_indexed: []` beside it states that nothing was missed — which is
the claim the build never made. `emptiness.py` puts it plainly: "the limit was not
reached" and "nobody looked" must not read the same.
So the keys are dropped entirely when the count is zero, and the caller distinguishes
the two cases by presence, as it does for every other optional measurement here.
@brief No stamped report means no key in the reply. @version 1
"""
from clew.mcp_server.emptiness import _scope_payload
from clew.query.models import IndexScope
stamped = IndexScope("declared", "why", 12, ("src",), (".c",), (".sh=3", ".yml=1"), 4)
unrecorded = IndexScope("declared", "why", 12, ("src",), (".c",))
assert _scope_payload(stamped)["not_indexed"] == [".sh=3", ".yml=1"]
assert _scope_payload(stamped)["not_indexed_count"] == 4
assert "not_indexed" not in _scope_payload(unrecorded)
assert "not_indexed_count" not in _scope_payload(unrecorded)1 more lines, not shown
Activity · 8 steps
test_the_query_layer_serves_what_the_build_stamped
None test_not_indexed_report.test_the_query_layer_serves_what_the_build_stamped(Path tmp_path)
`IndexScope.not_indexed` carries the stamped row.
tests/test_not_indexed_report.py:134
Checks
assert scope.not_indexed == (".sh=3", ".yml=1")assert scope.not_indexed_count == 4
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-QUERY-001 | measured | test_the_query_layer_serves_what_the_build_stamped → index_scope → connect |
| REQ-DDB-QUERY-003 | measured | test_the_query_layer_serves_what_the_build_stamped → index_scope → _indexed_paths → table_exists |
| REQ-DDB-QUERY-007 | measured | test_the_query_layer_serves_what_the_build_stamped → index_scope |
Source · 22 lines
def test_the_query_layer_serves_what_the_build_stamped(tmp_path: Path) -> None:
"""@brief `IndexScope.not_indexed` carries the stamped row. @version 1"""
db = tmp_path / "clew.db"
conn = sqlite3.connect(str(db))
try:
conn.execute("CREATE TABLE path (rowid INTEGER PRIMARY KEY, type INT, name TEXT)")
conn.execute("INSERT INTO path (type, name) VALUES (1, 'src/main.c')")
conn.execute("CREATE TABLE build_meta (key TEXT PRIMARY KEY, value TEXT)")
conn.executemany(
"INSERT INTO build_meta (key, value) VALUES (?, ?)",
[("scope.not_indexed", ".sh=3, .yml=1"), ("scope.not_indexed_count", "4")],
)
conn.commit()
finally:
conn.close()
scope = index_scope(db)
assert scope.not_indexed == (".sh=3", ".yml=1")
assert scope.not_indexed_count == 4