test_a_capped_candidate_list_discloses_the_real_total¶
Tests › tests/test_disambiguation.py
What this test is for
Why it exists
SILENT TRUNCATION ON THE ONE FIELD WHOSE JOB IS DISAMBIGUATION. `MAX_CANDIDATES` is 8 and `candidate_rows` sliced to it with no disclosure, so `dossier("main")` on mbedtls returned 8 of 143 `main` rows — and the one that mattered, the stub `main` a non-threading build compiles, was not among them. No `_limited` entry, no count, nothing saying a choice had been made, while `candidates` reads as "the identities this name has".
Verifies REQ-DDB-QUERY-010
Given
db = tmp_path / "many.db"conn = sqlite3.connect(str(db))
6 more
conn.execute( "CREATE TABLE memberdef (rowid_ INTEGER, name TEXT, kind TEXT, definition TEXT, " "file_id INTEGER, bodyfile_id INTEGER, bodystart INTEGER)" )over = _MAX_CANDIDATES + 5conn.executemany( "INSERT INTO memberdef(name, kind, definition, file_id, bodyfile_id, bodystart) " "VALUES('main', 'function', ?, ?, ?, 1)", [(f"int main{i}(void)", i, i) for i in range(over)], )conn.execute( "INSERT INTO memberdef(name, kind, definition, file_id, bodyfile_id, bodystart) " "VALUES('solo', 'function', 'int solo(void)', 1, 1, 1)" )conn.commit()conn.close()
When
_distinct_identities(db, "main")capped = _candidates_capped(db, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES})_candidates_capped(db, {"subject": "main", "candidates": [{}] * 2})
2 more
_candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES})_candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES})
Then
- ✓ _distinct_identities(db, "main") equals over
- ✓ capped is not None
- ✓ capped["total_available"] equals over
- ✓ capped["reason"] contains "policy"
- ✓ capped["how_to_narrow"] contains "SAMPLE"
- ✓ _candidates_capped(db, {"subject": "main", "candidates": [{}] * 2}) is None
- ✓ _candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES}) is None
- ✓ _candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES}) is None
What it exercises
The parts of the system's flows this test ran, measured by per-test coverage: lit steps ran in this test, dimmed ones did not, and ▶ marks where the test called in. Each title opens the whole flow with these steps lit.
Look up one name: everything the index holds about it · 3 of 226 steps
… 84 earlier steps
… 135 later steps
tests/test_disambiguation.py:466 · its file's page
What it checks (8)
assert _distinct_identities(db, "main") == over, "the total must be counted, not estimated"observes_distinct_identitiesassert capped is not None, "a list AT the cap with more rows behind it must disclose"observes_candidates_cappedviacappedassert capped["total_available"] == over, f"the total must be the real count; got {capped}"observes_candidates_cappedviacappedassert "policy" in capped["reason"], ( "the reason must say it is a policy cap — attributing it to response size sends a reader " "to shrink a payload that was never too big" )observes_candidates_cappedviacappedassert "SAMPLE" in capped["how_to_narrow"], "it must say the rows are a sample, not the set"observes_candidates_cappedviacappedassert _candidates_capped(db, {"subject": "main", "candidates": [{}] * 2}) is None, ( "below the cap nothing was dropped, so nothing may be disclosed" )observes_candidates_cappedassert ( _candidates_capped(db, {"subject": "solo", "candidates": [{}] * _MAX_CANDIDATES}) is None ), "a name AT the cap with no further rows behind it has lost nothing"observes_candidates_cappedassert ( _candidates_capped(None, {"subject": "main", "candidates": [{}] * _MAX_CANDIDATES}) is None ), "with no database the total is unknowable and must not be invented"observes_candidates_capped
Where the product reaches it
Call flow
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Requirements it verifies (1)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-QUERY-010 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-QUERY-001 measured
- REQ-DDB-QUERY-003 measured