test_search_total.py¶
tests/test_search_total.py
A search cut by its limit says how many rows there were (T1; 2.0.0).
test_a_cut_search_reports_the_true_total
None test_search_total.test_a_cut_search_reports_the_true_total(Path rich_db, Path repo_root, corpus, text)
limit=2 against a token with more matches: `_limited.total_available` is the full count.
Checks
assert full["count"] > 2 and "_limited" not in fullassert cut["count"] == 2assert cut["_limited"]["total_available"] == full["count"]assert cut["_limited"]["adjusted"] == {"results": f"{full['count']} -> 2"}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → _symbol_corpus → search_counted → _memberdef_corpora → _memberdef_candidates → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → lock_roster |
| REQ-DDB-QUERY-002 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → _files_corpus → directory_rollup |
| REQ-DDB-QUERY-003 | measured | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → kconfig_space → table_exists |
| REQ-DDB-QUERY-004 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → kconfig_space → _gates → _with_defaults → _in_default_build |
| REQ-DDB-QUERY-006 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → kconfig_space |
| REQ-DDB-QUERY-007 | measured | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → _prose_corpus → prose_emptiness |
| REQ-DDB-QUERY-011 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → lock_roster |
| REQ-DDB-QUERY-013 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → kconfig_space → _gates → _with_defaults → decided_default |
| REQ-DDB-QUERY-014 | measured | test_a_cut_search_reports_the_true_total → export_search |
| REQ-DDB-SCHEMA-011 | inferred | test_a_cut_search_reports_the_true_total → export_search → corpus_payload → lock_roster → nestings_on |
Source · 10 lines
def test_a_cut_search_reports_the_true_total(rich_db: Path, repo_root: Path, corpus, text) -> None:
"""@brief limit=2 against a token with more matches: `_limited.total_available` is the full count."""
full = export_search(rich_db, text, corpus=corpus, limit=1000, repo_root=repo_root)
assert full["count"] > 2 and "_limited" not in full
cut = export_search(rich_db, text, corpus=corpus, limit=2, repo_root=repo_root)
assert cut["count"] == 2
assert cut["_limited"]["total_available"] == full["count"]
assert cut["_limited"]["adjusted"] == {"results": f"{full['count']} -> 2"}
Activity · 6 steps
test_a_search_under_its_limit_has_no_limited_key
None test_search_total.test_a_search_under_its_limit_has_no_limited_key(Path rich_db, Path repo_root)
Absent, not `total_available == count`.
Checks
assert "_limited" not in export_search(rich_db, "return", corpus="symbols", limit=25)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-INDEX-004 | measured | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → _symbol_corpus → search_counted → _memberdef_corpora → _memberdef_candidates → symbol_provenance |
| REQ-DDB-QUERY-001 | measured | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → lock_roster |
| REQ-DDB-QUERY-002 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → _files_corpus → directory_rollup |
| REQ-DDB-QUERY-003 | measured | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → kconfig_space → table_exists |
| REQ-DDB-QUERY-004 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → kconfig_space → _gates → _with_defaults → _in_default_build |
| REQ-DDB-QUERY-006 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → kconfig_space |
| REQ-DDB-QUERY-007 | measured | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → _prose_corpus → prose_emptiness |
| REQ-DDB-QUERY-011 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → lock_roster |
| REQ-DDB-QUERY-013 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → kconfig_space → _gates → _with_defaults → decided_default |
| REQ-DDB-QUERY-014 | measured | test_a_search_under_its_limit_has_no_limited_key → export_search |
| REQ-DDB-SCHEMA-011 | inferred | test_a_search_under_its_limit_has_no_limited_key → export_search → corpus_payload → lock_roster → nestings_on |
Source · 3 lines
def test_a_search_under_its_limit_has_no_limited_key(rich_db: Path, repo_root: Path) -> None:
"""@brief Absent, not `total_available == count`."""
assert "_limited" not in export_search(rich_db, "return", corpus="symbols", limit=25)1 more lines, not shown
Activity · 1 steps
test_the_mcp_reply_carries_the_same_disclosure
None test_search_total.test_the_mcp_reply_carries_the_same_disclosure(Path rich_db, Path repo_root)
The MCP `search` tool, not only the export, says it was cut.
Checks
assert cut["_limited"]["total_available"] == full
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-MCP-003 | measured | |
| REQ-DDB-QUERY-001 | measured | |
| REQ-DDB-QUERY-014 | measured |
Source · 8 lines
def test_the_mcp_reply_carries_the_same_disclosure(rich_db: Path, repo_root: Path) -> None:
"""@brief The MCP `search` tool, not only the export, says it was cut."""
tools = QueryTools(lambda: rich_db, lambda: repo_root)
full = tools.search("return", corpus="code", limit=1000)["count"]
cut = tools.search("return", corpus="code", limit=3)
assert cut["_limited"]["total_available"] == full