From d57dc3f7d2a084be3b92f9c054bd140bd97fd3e0 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 3 Apr 2023 17:23:16 +0000 Subject: [PATCH] test(backups): test that we do return snapshot on backup --- selfprivacy_api/backup/restic_backuper.py | 1 + tests/test_graphql/test_backup.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/selfprivacy_api/backup/restic_backuper.py b/selfprivacy_api/backup/restic_backuper.py index 73292f0..cc81361 100644 --- a/selfprivacy_api/backup/restic_backuper.py +++ b/selfprivacy_api/backup/restic_backuper.py @@ -87,6 +87,7 @@ class ResticBackuper(AbstractBackuper): for message in messages: if message["message_type"] == "summary": return ResticBackuper._snapshot_from_fresh_summary(message, repo_name) + raise ValueError("no summary message in restic json output") @staticmethod def _snapshot_from_fresh_summary(message: object, repo_name) -> Snapshot: diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index 7683d4d..ec16306 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -130,6 +130,17 @@ def test_one_snapshot(backups, dummy_service): assert snap.service_name == dummy_service.get_id() +def test_backup_returns_snapshot(backups, dummy_service): + service_folder = dummy_service.get_location() + provider = Backups.provider() + name = dummy_service.get_id() + snapshot = provider.backuper.start_backup(service_folder, name) + + assert snapshot.id is not None + assert snapshot.service_name == name + assert snapshot.created_at is not None + + def test_restore(backups, dummy_service): service_folder = dummy_service.get_location() file_to_nuke = listdir(service_folder)[0]