test_detect_undeclared_accessor_families

Tests › tests/test_build_docs_db.py

passed Passed in the packaged run.

What this test is for

Why it exists

The advisory diagnostic surfaces set/get accessor FAMILIES (one function per key, shared long prefix) that no active pattern covers — both CamelCase (`Store_SetAreaData`) and snake+underscore (`Foo_Set_BAR`) — while rejecting the shapes that are NOT a data model: an object setter with no leading token (`set_level`), a lowercase command handler (`handle_get_stage_list_cmd`), a family below the key threshold, and a family already covered by a pattern.

Verifies REQ-DDB-PIPE-001 REQ-DDB-PIPE-010

Given

  1. functions = [ # CamelCase family (5 keys) — should be suggested. (1, "Store_SetAreaData", 1, 1), (2, "Store_SetBleData", 2, 2), (3, "Store_SetCleanStatus", 3, 3), (4, "Store_SetDockCoordData", 4, 4), (5, "Store_SetHeartbeat", 5, 5), # Object setters — no leading token before the verb ⇒ excluded. (6, "set_level", 6, 6), (7, "set_speed", 7, 7), # Lowercase command handler ⇒ excluded (key is a verb phrase, not a key). (8, "handle_get_stage_list_cmd", 8, 8), # Below-threshold family (only 2 keys) ⇒ excluded. (9, "Tiny_SetA", 9, 9), (10, "Tiny_SetB", 10, 10), # A family that IS covered by an active pattern ⇒ excluded. (11, "DataModel_Set_ALPHA", 11, 11), (12, "DataModel_Set_BETA", 12, 12), (13, "DataModel_Set_GAMMA", 13, 13), (14, "DataModel_Set_DELTA", 14, 14), ]
  2. db_path = _make_shared_key_db(tmp_path, functions)
  3. conn = sqlite3.connect(str(db_path))
→

When

  1. fams = detect_undeclared_accessor_families(conn, [NamePrefixPattern("DataModel_Set_")])
  2. conn.close()
  3. fam_map = {f.prefix: f.keys for f in fams}
  4. prefixes = set(fam_map)
→

Then

  1. ✓ fam_map.get("Store_Set") equals 5
  2. ✓ any(p.startswith("set_") for p in prefixes) is false
  3. ✓ any("handle" in p for p in prefixes) is false
  4. ✓ prefixes does not contain "Tiny_Set"
  5. ✓ any(p.startswith("DataModel_Set") for p in prefixes) is false

tests/test_build_docs_db.py:1675 · its file's page

What it checks (5)

  1. assert fam_map.get("Store_Set") == 5, ( f"Store_Set family (5 keys) should be suggested; got {fams}" ) observes detect_undeclared_accessor_families via fams
  2. assert not any(p.startswith("set_") for p in prefixes), "object setters must not cluster" not attributed
  3. assert not any("handle" in p for p in prefixes), "command handler must be excluded" not attributed
  4. assert "Tiny_Set" not in prefixes, "below-threshold family must be excluded" not attributed
  5. assert not any(p.startswith("DataModel_Set") for p in prefixes), "covered family excluded" not attributed

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_detect_undeclared_accessor_families→detect_undeclared_accessor_families→_make_shared_key_db

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_detect_undeclared_accessor_families · 5 checksdetect_undeclared_accessor_familiesREQ-DDB-CONFIG-007 · measureddetect_undeclared_accessor_familiesREQ-DDB-SCHEMA-005 · measured

Requirements it verifies (2)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-001catalogunknown
REQ-DDB-PIPE-010catalogunknown
Also reaches 2 requirements

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