feat: make Django configs drive backups and scheduling
Treat SQL-backed Django models as the source of truth for pobsync configuration, exporting runtime YAML only as a compatibility layer for the existing engine. Add a database-driven scheduler command, Docker scheduler services, schedule run-state fields, and tests for scheduler, config export, and retention behavior.
This commit is contained in:
24
src/pobsync_backend/tests/test_retention.py
Normal file
24
src/pobsync_backend/tests/test_retention.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from pobsync.retention import Snapshot, build_retention_plan
|
||||
|
||||
|
||||
class RetentionTests(SimpleTestCase):
|
||||
def test_always_keeps_newest_snapshot(self) -> None:
|
||||
snapshots = [
|
||||
Snapshot("scheduled", "old", "/x/old", datetime(2026, 5, 18, tzinfo=timezone.utc), "success", None),
|
||||
Snapshot("scheduled", "new", "/x/new", datetime(2026, 5, 19, tzinfo=timezone.utc), "failed", None),
|
||||
]
|
||||
|
||||
plan = build_retention_plan(
|
||||
snapshots,
|
||||
retention={"daily": 0, "weekly": 0, "monthly": 0, "yearly": 0},
|
||||
now=datetime(2026, 5, 19, tzinfo=timezone.utc),
|
||||
)
|
||||
|
||||
self.assertEqual(plan.keep, {"new"})
|
||||
self.assertEqual(plan.reasons["new"], ["newest"])
|
||||
Reference in New Issue
Block a user