- effort-estimate-report.md: updated metrics (~182 files, ~40K LOC), added enhancement breakdown, updated comparative analysis
- spec.md: status → Core + Enhancement complete, added Enhancement Implementation Notes
- plan.md: all enhancement components marked ✅, metrics updated
- tasks.md: all 26 enhancement tasks (T135-T160) → [x], closure summary updated
- quickstart.md: added §10 Direct Database Insert flow
- data-model.md, research.md, contracts/modules.md, ux_reference.md, spec.ru.md, checklists/requirements.md: dates, statuses, metrics aligned
- all documents now reflect 2026-06-11 state: ~174-182 files, ~39-40K LOC, ~580 pytest, ~68 vitest
4.8 KiB
4.8 KiB
Test Documentation: Feature 028 Enhancement
Direct DB Insert + Database Connection Settings
Date: 2026-06-10
Feature: 028-llm-datasource-supeset
Phases: 12 (US12 Connection Settings) + 13 (US11 Direct DB Insert)
Mocking Audit Report
Summary
| Total tests scanned | Total mocks | Valid | Violations | Logic Mirrors | Uncertain |
|---|---|---|---|---|---|
| 3 backend files (47 tests) | 31 | 29 | 0 | 0 | 2 |
Clean Tests (No Violations)
| File | Assertions |
|---|---|
test_orchestrator_direct_db.py |
DbExecutor/ConnectionService/SupersetSqlLabExecutor at [EXT] boundary |
test_db_executor.py |
_execute_pg/ch/mysql annotated as [EXT:Database] driver wrappers |
test_connection_service.py |
ConfigManager at [EXT] boundary; dialect drivers annotated |
Documented AUDIT_NOTEs
| File | Target | Rationale |
|---|---|---|
test_db_executor.py |
_execute_pg, _execute_ch, _execute_mysql |
Thin wrappers around [EXT:asyncpg], [EXT:clickhouse-connect], [EXT:pymysql] |
test_connection_service.py |
_test_postgresql, _test_clickhouse, _test_mysql |
Thin wrappers around [EXT:asyncpg], [EXT:clickhouse-connect], [EXT:pymysql] |
test_connection_service.py |
_find_blocking_jobs |
Thin wrapper around [EXT:SQLAlchemy] |
Coverage Summary
Commands Executed
cd backend && source .venv/bin/activate
python -m pytest tests/test_connection_service.py -v # 32 passed
python -m pytest tests/test_db_executor.py -v # 14 passed
python -m pytest tests/test_orchestrator_direct_db.py -v # 5 passed
python -m ruff check --select E,F <all src + test files> # All passed
cd frontend
npm run test -- --run src/lib/components/translate/__tests__/InsertMethodSelector.test.ts # 5 passed
npm run build # ✅
Pass/Fail Per Layer
| Layer | Tests | Pass | Fail |
|---|---|---|---|
| Backend — ConnectionService | 32 | 32 | 0 |
| Backend — DbExecutor | 14 | 14 | 0 |
| Backend — Orchestrator SQL | 5 | 5 | 0 |
| Frontend — InsertMethodSelector | 5 | 5 | 0 |
| Total | 56 | 56 | 0 |
Module Coverage
| Module | Lines | Tests | Key Coverage Areas |
|---|---|---|---|
connection_service.py |
440 | 32 | CRUD, encryption round-trip, dialect validation, delete blocking, test connection, ref validation |
db_executor.py |
280 | 14 | Dialect routing (pg/ch/mysql), error handling, pool caching, missing driver fallback |
orchestrator_sql.py (+dispatch) |
+90 | 5 | Direct DB dispatch, connection snapshot, sqllab fallback |
InsertMethodSelector.svelte |
120 | 5 | Default state, direct_db switch, empty connections, dialect filtering, test button |
ConnectionsTab.svelte |
280 | — | Browser-verified (manual) |
Semantic Audit Verdict
| Check | Status |
|---|---|
| Contract density matches complexity (C1-C5) | ✅ All new contracts tagged correctly |
| Belief runtime in C4/C5 flows | ✅ orchestrator_sql.py uses belief_scope() |
| Rejected-path regression (ADR-0004) | ✅ DbExecutor = parallel path, documented @NOTE + @see |
| Rejected-path regression (superset_executor.py) | ✅ Guardrail scoped to that executor; DbExecutor separate |
| Logic coherence: route → dialect → pool → result | ✅ Verified at 3 test levels |
model_validator: direct_db ⇒ connection_id required |
✅ Pydantic schema validation |
| Connection snapshot excludes password | ✅ FR-067 + T149 code + test |
ADR Guardrail Status
| ADR / Guardrail | Protected By | Test Evidence |
|---|---|---|
| ADR-0004 (No DB for plugins) | Core.DbExecutor contract notes core service vs. plugin |
test_direct_db_dispatch |
| superset_executor @REJECTED (Direct bypass) | @see Core.DbExecutor |
test_sqllab_dispatch_by_default |
| FR-072 (Delete blocked by jobs) | _find_blocking_jobs check |
test_delete_blocked_by_jobs |
| FR-070 (Password encryption) | Fernet via EncryptionManager | test_encryption_round_trip |
| Snapshot isolation (run config) | connection_snapshot on run |
test_connection_snapshot_stored |
Remaining Risk / Debt
| Item | Severity | Status |
|---|---|---|
_find_blocking_jobs patches SUT method |
LOW | Annotated [EXT:SQLAlchemy]; real DB context required for live query test |
_execute_* patches (3 dialect drivers) |
LOW | Annotated [EXT:Database]; real driver testing needs testcontainers |
| Frontend vitest for ConnectionsTab | MEDIUM | Deferred; complex i18n/toast/API mocking setup |
| Alembic migration not applied | MEDIUM | Script generated; apply via alembic upgrade head on real DB |
Missing @UX_TEST on 10 components |
LOW | Pre-existing; deferred from earlier analysis |