test_detect_undeclared_accessor_families¶
Tests › tests/test_build_docs_db.py
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
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), ]db_path = _make_shared_key_db(tmp_path, functions)conn = sqlite3.connect(str(db_path))
When
fams = detect_undeclared_accessor_families(conn, [NamePrefixPattern("DataModel_Set_")])conn.close()fam_map = {f.prefix: f.keys for f in fams}prefixes = set(fam_map)
Then
- ✓ fam_map.get("Store_Set") equals 5
- ✓ any(p.startswith("set_") for p in prefixes) is false
- ✓ any("handle" in p for p in prefixes) is false
- ✓ prefixes does not contain "Tiny_Set"
- ✓ 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)
assert fam_map.get("Store_Set") == 5, ( f"Store_Set family (5 keys) should be suggested; got {fams}" )observesdetect_undeclared_accessor_familiesviafamsassert not any(p.startswith("set_") for p in prefixes), "object setters must not cluster"not attributedassert not any("handle" in p for p in prefixes), "command handler must be excluded"not attributedassert "Tiny_Set" not in prefixes, "below-threshold family must be excluded"not attributedassert 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
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 (2)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-PIPE-001 | catalog | unknown |
| REQ-DDB-PIPE-010 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-CONFIG-007 measured
- REQ-DDB-SCHEMA-005 measured