From 09c79b34776a87f96b977f60aeef3e610a7fd81d Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 14 Jun 2023 11:14:52 +0000 Subject: [PATCH] test(backups): snapshot query --- tests/test_graphql/test_api_backup.py | 38 ++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/tests/test_graphql/test_api_backup.py b/tests/test_graphql/test_api_backup.py index 1d944f4..c0961b7 100644 --- a/tests/test_graphql/test_api_backup.py +++ b/tests/test_graphql/test_api_backup.py @@ -1,10 +1,18 @@ from tests.test_graphql.test_backup import dummy_service, backups, raw_dummy_service +from tests.common import generate_backup_query -# from tests.common import generate_api_query - -# from selfprivacy_api.graphql.mutations.backup_mutations import BackupMutations from selfprivacy_api.jobs import Jobs, JobStatus +API_SNAPSHOTS_QUERY = """ +allSnapshots { + id + service { + id + } + createdAt +} +""" + API_BACK_UP_MUTATION = """ mutation TestBackupService($service_id: String) { startBackup(serviceId: $service_id) { @@ -31,6 +39,30 @@ def api_backup(authorized_client, service): return response +def get_data(response): + assert response.status_code == 200 + response = response.json() + assert response["data"] is not None + data = response["data"] + return data + + +def api_snapshots(authorized_client, service): + response = authorized_client.post( + "/graphql", + json={"query": generate_backup_query([API_SNAPSHOTS_QUERY])}, + ) + data = get_data(response) + result = data["backup"]["allSnapshots"] + assert result is not None + return result + + +def test_snapshots_empty(authorized_client, dummy_service): + snaps = api_snapshots(authorized_client, dummy_service) + assert snaps == [] + + def test_start_backup(authorized_client, dummy_service): response = api_backup(authorized_client, dummy_service) assert response["data"]["startBackup"]["success"] is True