Jobs download new chapters, recheck chapters, replace the book, update metadata or rebuild from stored chapters. Locked metadata fields keep their values. A scheduler queues updates. An update finds the library book of a story through CWA, and fails with an error if it cannot, so that it never makes a duplicate book.
26 lines
982 B
Python
26 lines
982 B
Python
"""Daily backups of the database and personal.ini."""
|
|
|
|
import sqlite3
|
|
from datetime import date
|
|
|
|
from bindery.backup import daily_backup
|
|
from bindery.store import Store
|
|
|
|
|
|
def test_one_backup_a_day_and_only_the_newest_are_kept(tmp_path):
|
|
store = Store(tmp_path / "bindery.db")
|
|
store.create_story("https://example.com/s/1", "example.com", "T", "A", [])
|
|
ini = tmp_path / "personal.ini"
|
|
ini.write_text("[defaults]\n")
|
|
folder = tmp_path / "backups"
|
|
for day in range(1, 11):
|
|
daily_backup(store, folder, ini, 7, date(2026, 9, day))
|
|
assert daily_backup(store, folder, ini, 7, date(2026, 9, 10)) is None
|
|
names = sorted(p.name for p in folder.iterdir())
|
|
assert names == [f"bindery-2026-09-{d:02}.db" for d in range(4, 11)] + [
|
|
f"personal-2026-09-{d:02}.ini" for d in range(4, 11)
|
|
]
|
|
copy = sqlite3.connect(folder / "bindery-2026-09-10.db")
|
|
assert copy.execute("SELECT title FROM stories").fetchall() == [("T",)]
|
|
copy.close()
|