test_lookup_class_lists_candidates_when_the_name_is_ambiguous

Tests › tests/test_query.py

passed Passed in the packaged run.

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

  1. db = _class_db(tmp_path)
→

When

  1. entry = q.lookup_class(db, "PolygonWidget")
  2. names = [c.qualified for c in entry.candidates]
  3. for candidate in entry.candidates: selected = q.lookup_class(db, candidate.qualified) assert selected is not None assert selected.name == candidate.qualified
→

Then

  1. ✓ entry is not None
  2. ✓ entry.name equals "demo::shape::PolygonWidget"
  3. ✓ names contains "demo::shape::PolygonWidget"
  4. ✓ names contains "demo::shape::RoundedPolygonWidget"
  5. ✓ names contains "std::PolygonWidget_traits"
  6. ✓ [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

callercallercallercallerclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pyclew/query/recovery.pydossier18. _documentation_mentions → table_exists18table_exists19. _documentation_mentions → has_columns19has_columns20. has_columns → table_exists20table_exists▶ test enters21–22. _hint_from → _name_exists21_name_exists +1 more

… 204 later steps

2 more

tests/test_query.py:1355 · its file's page

What it checks (8)

  1. assert entry is not None observes lookup_class via entry
  2. assert entry.name == "demo::shape::PolygonWidget" observes lookup_class via entry
  3. assert "demo::shape::PolygonWidget" in names not attributed
  4. assert "demo::shape::RoundedPolygonWidget" in names not attributed
  5. assert "std::PolygonWidget_traits" in names not attributed
  6. assert [c.kind for c in entry.candidates] == ["class"] * len(names) observes lookup_class via entry
  7. assert selected is not None observes lookup_class via selected
  8. assert selected.name == candidate.qualified observes lookup_class via selected

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

test_lookup_class_lists_candidates_when_the_name_is_ambiguous→_class_db→lookup_class

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.

test_lookup_class_lists_candidates_when_the_name_is_ambiguous · 8 checkslookup_classREQ-DDB-QUERY-001 · measuredlookup_classtable_existsREQ-DDB-QUERY-003 · measuredlookup_classREQ-DDB-QUERY-010 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-QUERY-002catalogunknown
Also reaches 3 requirements

Its run touches their code; that is reach, not proof.