mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-05 11:03:12 +00:00
test(backups): snapshot query
This commit is contained in:
parent
8554879dc2
commit
928f026e7c
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue