test_lookup_class_lists_candidates_when_the_name_is_ambiguous¶
Tests › tests/test_query.py
What this test is for
Why it exists
gh#315. `lookup_class` fetches every substring match and returns the single best-ranked one, silently discarding the rest — so a caller asking for `PolygonWidget` in a repo that also has `RoundedPolygonWidget` is told about one class and never learns the other exists. Every other disambiguating surface (`resolve_symbol` / `dossier` / `chain_trace` / `source`) reports its rejects; this one did not.
Verifies REQ-DDB-QUERY-002
Given
db = _class_db(tmp_path)
When
entry = q.lookup_class(db, "PolygonWidget")names = [c.qualified for c in entry.candidates]for candidate in entry.candidates: selected = q.lookup_class(db, candidate.qualified) assert selected is not None assert selected.name == candidate.qualified
Then
- ✓ entry is not None
- ✓ entry.name equals "demo::shape::PolygonWidget"
- ✓ names contains "demo::shape::PolygonWidget"
- ✓ names contains "demo::shape::RoundedPolygonWidget"
- ✓ names contains "std::PolygonWidget_traits"
- ✓ [c.kind for c in entry.candidates] equals ["class"] * len(names)
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 · 1 of 226 steps
… 17 earlier steps
… 204 later steps
2 more
- clew — `main` (clew/cli.py) · 1 of 400 steps
- `main` (scripts/export_parity.py) · 1 of 203 steps
tests/test_query.py:1355 · its file's page
What it checks (8)
assert entry is not Noneobserveslookup_classviaentryassert entry.name == "demo::shape::PolygonWidget"observeslookup_classviaentryassert "demo::shape::PolygonWidget" in namesnot attributedassert "demo::shape::RoundedPolygonWidget" in namesnot attributedassert "std::PolygonWidget_traits" in namesnot attributedassert [c.kind for c in entry.candidates] == ["class"] * len(names)observeslookup_classviaentryassert selected is not Noneobserveslookup_classviaselectedassert selected.name == candidate.qualifiedobserveslookup_classviaselected
Where the product reaches it
No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.
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-002 | catalog | unknown |
Also reaches 3 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-QUERY-001 measured
- REQ-DDB-QUERY-003 measured
- REQ-DDB-QUERY-010 measured