From d9dab29fe87937ce0b83c8efce373ec007839540 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Fri, 14 Apr 2023 13:06:17 +0000 Subject: [PATCH] test(backups): test 2-folder restoration --- tests/test_graphql/test_backup.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/test_graphql/test_backup.py b/tests/test_graphql/test_backup.py index a14d268..d0f5d00 100644 --- a/tests/test_graphql/test_backup.py +++ b/tests/test_graphql/test_backup.py @@ -163,21 +163,31 @@ def test_backup_returns_snapshot(backups, dummy_service): def test_restore(backups, dummy_service): - service_folder = dummy_service.get_folders()[0] - file_to_nuke = listdir(service_folder)[0] - assert file_to_nuke is not None - path_to_nuke = path.join(service_folder, file_to_nuke) + paths_to_nuke = [] + contents = [] + + for service_folder in dummy_service.get_folders(): + file_to_nuke = listdir(service_folder)[0] + assert file_to_nuke is not None + path_to_nuke = path.join(service_folder, file_to_nuke) + paths_to_nuke.append(path_to_nuke) + with open(path_to_nuke, "r") as file: + contents.append(file.read()) Backups.back_up(dummy_service) snap = Backups.get_snapshots(dummy_service)[0] assert snap is not None - assert path.exists(path_to_nuke) - remove(path_to_nuke) - assert not path.exists(path_to_nuke) + for p in paths_to_nuke: + assert path.exists(p) + remove(p) + assert not path.exists(p) Backups.restore_service_from_snapshot(dummy_service, snap.id) - assert path.exists(path_to_nuke) + for p, content in zip(paths_to_nuke, contents): + assert path.exists(p) + with open(p, "r") as file: + assert file.read() == content def test_sizing(backups, dummy_service): @@ -381,4 +391,4 @@ def test_services_to_back_up(backups, dummy_service): services = Backups.services_to_back_up(now) assert len(services) == 1 - assert services[0].get_id() == dummy_service.get_id() \ No newline at end of file + assert services[0].get_id() == dummy_service.get_id()