b49efdcb11
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 11s
CI & Build / integration (push) Successful in 30s
CI & Build / Python tests (push) Failing after 31s
CI & Build / Build & push image (push) Has been skipped
Narrow Scribe to a Claude-Code work system-of-record (milestone #194, decision note #1759). Wholesale removal per rule #22 — backend + schema half. Calendar/events + CalDAV: delete models/event, services/{events,caldav, caldav_sync}, routes/events, mcp/tools/events; strip event branches from backup (bump v3->v4), dashboard (upcoming_events), trash, recent, and the mcp server read-only allowlist + instructions. Typed entities (person/place/list): delete mcp/tools/entities; drop the notes.metadata (entity_meta) column from model/service/routes and the knowledge browse service. note_type STAYS — it also marks 'process' notes. Scheduler: event_scheduler -> recurrence_scheduler, keeping only the recurring-task spawn job (drops event reminders + CalDAV sync). Schema: migration 0069 drops the events table + notes.metadata column + orphan caldav settings rows (faithful downgrade recreates them). KEEP: recurrence.py (task recurrence), notifications task reminders, graph view, and every work surface. Frontend + plugin/docs true-up follow next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BPtbSzA4JLMAKgFZ8VTg7Q
73 lines
2.2 KiB
Python
73 lines
2.2 KiB
Python
"""Unit tests for the v4 backup export contract.
|
|
|
|
CI runs pytest with no database, so these cover the parts that don't need one:
|
|
the version/coverage constants, the pure join-table row helpers, and the export
|
|
dict shape (via a mocked session). Full FK-remapping round-trip is exercised
|
|
manually against a real DB (export a backup, confirm rulebooks appear).
|
|
"""
|
|
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from scribe.services import backup
|
|
|
|
|
|
def test_backup_version_is_v4():
|
|
assert backup.BACKUP_VERSION == 4
|
|
|
|
|
|
def test_not_included_lists_the_known_gaps():
|
|
# The deferred tables must be surfaced explicitly, not silently dropped.
|
|
for table in ("groups", "project_shares", "note_shares", "api_keys", "embeddings"):
|
|
assert table in backup._NOT_INCLUDED
|
|
|
|
|
|
def test_join_table_row_helpers_are_pure():
|
|
subs = [SimpleNamespace(project_id=1, rulebook_id=2)]
|
|
rsup = [SimpleNamespace(project_id=1, rule_id=9)]
|
|
tsup = [SimpleNamespace(project_id=1, topic_id=7)]
|
|
assert backup._subscription_rows(subs) == [{"project_id": 1, "rulebook_id": 2}]
|
|
assert backup._rule_suppression_rows(rsup) == [{"project_id": 1, "rule_id": 9}]
|
|
assert backup._topic_suppression_rows(tsup) == [{"project_id": 1, "topic_id": 7}]
|
|
|
|
|
|
class _Result:
|
|
def scalars(self):
|
|
return self
|
|
|
|
def all(self):
|
|
return []
|
|
|
|
|
|
class _Session:
|
|
async def execute(self, *a, **k):
|
|
return _Result()
|
|
|
|
async def get(self, *a, **k):
|
|
return None
|
|
|
|
|
|
class _CM:
|
|
async def __aenter__(self):
|
|
return _Session()
|
|
|
|
async def __aexit__(self, *a):
|
|
return False
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_export_full_backup_contains_v3_sections():
|
|
with patch("scribe.services.backup.async_session", lambda: _CM()):
|
|
out = await backup.export_full_backup()
|
|
|
|
assert out["version"] == 4
|
|
assert out["scope"] == "full"
|
|
assert "api_keys" in out["_not_included"]
|
|
# The sections v2 silently dropped must now be present (empty here).
|
|
for key in ("rulebooks", "rulebook_topics", "rules",
|
|
"rulebook_subscriptions", "rule_suppressions",
|
|
"topic_suppressions"):
|
|
assert key in out, f"missing v3 section: {key}"
|
|
assert out[key] == []
|