fix: add close/context-manager to diagnosis store; tighten import boundary
This commit is contained in:
@@ -4,7 +4,12 @@
|
||||
load 往返还原,以及 INFRA 行的可空字段处理。
|
||||
"""
|
||||
|
||||
from adapters.baseline_diagnosis_store import DiagnosisSignalRow, SqliteDiagnosisSignalStore
|
||||
import sqlite3
|
||||
|
||||
import pytest
|
||||
|
||||
from adapters.baseline_diagnosis_store import SqliteDiagnosisSignalStore
|
||||
from core.evolution.types import DiagnosisSignalRow
|
||||
|
||||
|
||||
def _store(tmp_path):
|
||||
@@ -78,3 +83,16 @@ def test_null_fields_for_infra_row(tmp_path):
|
||||
)
|
||||
rows = s.load("r", "fp")
|
||||
assert rows[0].error_type is None and rows[0].evolution_target is None and rows[0].infra is True
|
||||
|
||||
|
||||
def test_context_manager_closes_connection(tmp_path):
|
||||
# with 块退出后连接关闭,再操作应报 ProgrammingError
|
||||
with SqliteDiagnosisSignalStore(str(tmp_path / "h.db")) as s:
|
||||
s.upsert(
|
||||
DiagnosisSignalRow(
|
||||
"q4", "v4", "r", "fp", "Counting", None, None, "T0", None, False, True, None
|
||||
)
|
||||
)
|
||||
assert s.done_question_ids("r", "fp") == {"q4"}
|
||||
with pytest.raises(sqlite3.ProgrammingError):
|
||||
s.done_question_ids("r", "fp")
|
||||
|
||||
Reference in New Issue
Block a user