From 8ff65fe7b13e446f9f1a8dce1c54631704d9662a Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 23 Sep 2024 12:22:57 +0000 Subject: [PATCH] test(backup): total restore endpoint testing --- tests/test_graphql/test_api_backup.py | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/test_graphql/test_api_backup.py b/tests/test_graphql/test_api_backup.py index bfb57c4..845695f 100644 --- a/tests/test_graphql/test_api_backup.py +++ b/tests/test_graphql/test_api_backup.py @@ -55,7 +55,7 @@ mutation TestForcedAutobackup { API_TOTAL_RESTORE = """ mutation TestTotalRestore { backup { - fullRestore{ + restoreAll{ success message code @@ -323,6 +323,17 @@ def api_total_backup(authorized_client): return response +def api_restore_all(authorized_client): + response = authorized_client.post( + "/graphql", + json={ + "query": API_TOTAL_RESTORE, + "variables": {}, + }, + ) + return response + + def api_init( authorized_client, kind, @@ -700,3 +711,32 @@ def test_last_slice(authorized_client, only_dummy_service_and_api, backups): snaps = api_last_slice(authorized_client) assert len(snaps) == 2 + + +def test_backup_all_restore_all( + authorized_client, + backups, + generic_userdata, + dkim_file, + only_dummy_service_and_api, + catch_nixos_rebuild_calls, +): + dummy_service = only_dummy_service_and_api + fp = catch_nixos_rebuild_calls + fp.pass_command(["restic", fp.any()]) + fp.keep_last_process(True) + fp.pass_command(["rclone", fp.any()]) + fp.keep_last_process(True) + fp.pass_command(["lsblk", fp.any()]) + fp.keep_last_process(True) + + response = api_total_backup(authorized_client) + data = get_data(response)["backup"]["totalBackup"] + assert_ok(data) + + assert len(api_snapshots(authorized_client)) == 2 + response = api_restore_all(authorized_client) + data = get_data(response)["backup"]["restoreAll"] + assert_ok(data) + # Just in case + assert len(api_snapshots(authorized_client)) == 2