test_name_accessors_degrade_gracefully_on_table_less_db

Tests › tests/test_query.py

passed Passed in the packaged run.

What this test is for

Why it exists

#41: a corrupt/unbuilt db (valid sqlite, no pipeline tables) must make EVERY name-based accessor degrade to "not found" (empty/None), never raise a raw sqlite OperationalError — matching the table_exists convention already pervasive across the query layer. Before the fix callers/callees guarded their table, but dossier/source/search/thread_of/chain_trace/resolve_symbol queried memberdef cold and raised, so the same corrupt db gave inconsistent behaviour across the tier-1 surface.

Given

  1. p = tmp_path / "corrupt.db"
  2. conn = sqlite3.connect(p)
3 more
  1. conn.execute("CREATE TABLE junk(x)")
  2. conn.commit()
  3. conn.close()
→

When

  1. q.callers(p, "x")
  2. q.callees(p, "x")
  3. q.search(p, "x")
5 more
  1. q.thread_of(p, "x")
  2. q.function_dossier(p, "x")
  3. q.source(p, "x", tmp_path)
  4. q.resolve_symbol(p, "x")
  5. q.chain_trace(p, "x")
→

Then

  1. ✓ q.callers(p, "x") equals []
  2. ✓ q.callees(p, "x") equals []
  3. ✓ q.search(p, "x") equals []
  4. ✓ q.thread_of(p, "x") equals []
  5. ✓ q.function_dossier(p, "x") is None
  6. ✓ q.source(p, "x", tmp_path) is None
  7. ✓ q.resolve_symbol(p, "x") is None
  8. ✓ q.chain_trace(p, "x") is not 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.

clew — `main` (clew/cli.py) · 19 of 400 steps

… 211 earlier steps

command-line usercommand-line usercommand-line usercommand-line userclew/query/symbols.pyclew/query/symbols.pyclew/query/symbols.pyclew/query/symbols.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyother filesother filesother filesother filesloop (line 1576)loopmain212. corpus_payload → _symbol_corpus212_symbol_corpus213. _symbol_corpus → search_counted213search_counted214. search_counted → connect214connect▶ test enters215–216. search_counted → _memberdef_corpora215_memberdef_corpora +1 more217. _expansion_sql → has_columns217has_columns218. has_columns → table_exists218table_exists219. _memberdef_corpora → _memberdef_candidates219_memberdef_candidates220. _memberdef_candidates → table_exists220table_exists221. _memberdef_candidates → documented_first221documented_first222. documented_first → records_provenance222records_provenance

… 7 steps between

command-line usercommand-line usercommand-line usercommand-line usercommand-line userclew/query/symbols.pyclew/query/symbols.pyclew/query/symbols.pyclew/query/symbols.pyclew/query/symbols.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/_common.pyclew/query/corpus.pyclew/query/corpus.pyclew/query/corpus.pyclew/query/corpus.pyclew/query/corpus.pyother filesother filesother filesother filesother filesloop (line 1507)loopmain230. _memberdef_candidates → _search_rank230_search_rank231. _memberdef_candidates → symbol_provenance231symbol_provenance232. search_counted → _class_candidates232_class_candidates▶ test enters233. _class_candidates → _search_rank233_search_rank234. _class_candidates → class_rows234class_rows235. class_rows → table_exists235table_exists236. class_rows → strip_xml236strip_xml237. search_counted → _config_candidates237_config_candidates238. _config_candidates → _search_rank238_search_rank239. _config_candidates → gate_symbol_rows239gate_symbol_rows240. gate_symbol_rows → table_exists240table_exists241. gate_symbol_rows → has_columns241has_columns242. search_counted → _file_candidates242_file_candidates243. _file_candidates → self_declared_paths243self_declared_paths244–245. _file_candidates → _search_rank244_search_rank +1 more246. _file_candidates → file_doc_rows246file_doc_rows247. file_doc_rows → table_exists247table_exists248. _file_candidates → undocumented_path_rows248undocumented_path_rows249. undocumented_path_rows → table_exists249table_exists250. undocumented_path_rows → has_columns250has_columns251. undocumented_path_rows → table_exists251table_exists

… 149 later steps

3 more

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

What it checks (8)

  1. assert q.callers(p, "x") == [] observes callers
  2. assert q.callees(p, "x") == [] observes callees
  3. assert q.search(p, "x") == [] observes search
  4. assert q.thread_of(p, "x") == [] observes thread_of
  5. assert q.function_dossier(p, "x") is None observes function_dossier
  6. assert q.source(p, "x", tmp_path) is None observes source
  7. assert q.resolve_symbol(p, "x") is None observes resolve_symbol
  8. assert q.chain_trace(p, "x") is not None observes chain_trace

Where the product reaches it

  • dossier → _chain_for → chain_trace (flow)

Call flow

test_name_accessors_degrade_gracefully_on_table_less_db→callers→callees→search→thread_of→function_dossier→source→resolve_symbol→chain_trace

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_name_accessors_degrade_gracefully_on_table_less_db · 8 checkssourcesymbol_provenanceREQ-DDB-INDEX-004 · inferredfunction_dossier… 5 calls …is_python_treeREQ-DDB-PIPE-003 · inferredfunction_dossier… 5 calls …_parseable_fileREQ-DDB-PIPE-011 · inferredfunction_dossier… 5 calls …has_languageREQ-DDB-PIPE-012 · inferredsourceREQ-DDB-QUERY-001 · measuredchain_traceREQ-DDB-QUERY-002 · measuredresolve_symbolREQ-DDB-QUERY-003 · measuredfunction_dossierREQ-DDB-QUERY-004 · measuredchain_trace_make_nodeREQ-DDB-QUERY-005 · inferredfunction_dossier_dossier_conngates_coveringREQ-DDB-QUERY-006 · inferredsearchsearch_counted_class_candidatesclass_rowsREQ-DDB-QUERY-007 · measuredfunction_dossierREQ-DDB-QUERY-009 · measured

and 4 more requirement paths, listed below.

Also reaches 16 requirements

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