mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-06 21:02:04 +00:00
Add backup interval setting and throttled backups
This commit is contained in:
1 parent
51acd21478
commit
ba53cf2332
6 files changed
+72
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import time
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from helpers import create_vault, TEST_SEED, TEST_PASSWORD
|
||||
|
||||
from password_manager.backup import BackupManager
|
||||
from password_manager.config_manager import ConfigManager
|
||||
|
||||
|
||||
def test_backup_interval(monkeypatch):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
fp_dir = Path(tmpdir)
|
||||
vault, _ = create_vault(fp_dir, TEST_SEED, TEST_PASSWORD)
|
||||
cfg_mgr = ConfigManager(vault, fp_dir)
|
||||
cfg_mgr.set_backup_interval(10)
|
||||
backup_mgr = BackupManager(fp_dir, cfg_mgr)
|
||||
|
||||
vault.save_index({"entries": {}})
|
||||
|
||||
monkeypatch.setattr(time, "time", lambda: 1000)
|
||||
backup_mgr.create_backup()
|
||||
first = fp_dir / "backups" / "entries_db_backup_1000.json.enc"
|
||||
assert first.exists()
|
||||
|
||||
monkeypatch.setattr(time, "time", lambda: 1005)
|
||||
backup_mgr.create_backup()
|
||||
second = fp_dir / "backups" / "entries_db_backup_1005.json.enc"
|
||||
assert not second.exists()
|
||||
|
||||
monkeypatch.setattr(time, "time", lambda: 1012)
|
||||
backup_mgr.create_backup()
|
||||
third = fp_dir / "backups" / "entries_db_backup_1012.json.enc"
|
||||
assert third.exists()
|
||||
Reference in new issue
Block a user