Coverage for src / local_deep_research / web / warning_checks / backup.py: 100%
23 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:55 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-14 23:55 +0000
1"""Backup status warning checks.
3Pure functions that take primitive values and return warning dicts (or None).
4"""
6from typing import Optional
9def check_backup_disabled(
10 backup_enabled: bool, dismissed: bool
11) -> Optional[dict]:
12 """Warn if automatic backups are disabled."""
13 if backup_enabled:
14 return None
15 if dismissed:
16 return None
18 return {
19 "type": "backup_disabled",
20 "icon": "💾",
21 "title": "Database Backups Disabled",
22 "message": (
23 "Automatic database backups are disabled. Without backups, "
24 "data cannot be recovered if the database is corrupted. "
25 "Enable backups in Settings \u203a Backup."
26 ),
27 "dismissKey": "app.warnings.dismiss_backup_disabled",
28 }
31def check_no_backups_exist(
32 backup_enabled: bool, backup_count: int, dismissed: bool
33) -> Optional[dict]:
34 """Warn if backups are enabled but none exist yet."""
35 if not backup_enabled:
36 return None
37 if backup_count > 0:
38 return None
39 if dismissed:
40 return None
42 return {
43 "type": "no_backups",
44 "icon": "📁",
45 "title": "No Backups Found",
46 "message": (
47 "No database backups have been created yet. A backup will "
48 "be created automatically on your next login. You can "
49 "configure backup settings in Settings \u203a Backup."
50 ),
51 "dismissKey": "app.warnings.dismiss_no_backups",
52 }
55def check_backup_healthy(
56 backup_enabled: bool,
57 backup_count: int,
58 total_size_human: str,
59 dismissed: bool,
60) -> Optional[dict]:
61 """Show positive backup status info (dismissable)."""
62 if not backup_enabled:
63 return None
64 if backup_count == 0:
65 return None
66 if dismissed:
67 return None
69 return {
70 "type": "backup_info",
71 "icon": "✅",
72 "title": "Database Backup Active",
73 "message": (
74 f"{backup_count} backup{'s' if backup_count > 1 else ''} "
75 f"({total_size_human}) on disk. Encrypted backups cannot be "
76 "compressed, so each backup equals your database size "
77 "(which can be large if PDFs are stored in the database). "
78 "Backups are created once per day on login. Manage backups "
79 "in Settings \u203a Backup."
80 ),
81 "dismissKey": "app.warnings.dismiss_backup_info",
82 }