mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-23 09:16:51 +00:00
test(backups): test forgetting via API
This commit is contained in:
parent
bba837530a
commit
2934e2beca
|
@ -94,6 +94,18 @@ mutation TestRestoreService($snapshot_id: String!) {
|
|||
}
|
||||
"""
|
||||
|
||||
API_FORGET_MUTATION = """
|
||||
mutation TestForgetSnapshot($snapshot_id: String!) {
|
||||
backup {
|
||||
forgetSnapshot(snapshotId: $snapshot_id) {
|
||||
success
|
||||
message
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
API_SNAPSHOTS_QUERY = """
|
||||
allSnapshots {
|
||||
id
|
||||
|
@ -143,6 +155,17 @@ def api_backup(authorized_client, service):
|
|||
return response
|
||||
|
||||
|
||||
def api_forget(authorized_client, snapshot_id):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={
|
||||
"query": API_FORGET_MUTATION,
|
||||
"variables": {"snapshot_id": snapshot_id},
|
||||
},
|
||||
)
|
||||
return response
|
||||
|
||||
|
||||
def api_set_period(authorized_client, period):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -370,3 +393,30 @@ def test_reload_snapshots(authorized_client, dummy_service):
|
|||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 1
|
||||
|
||||
|
||||
def test_forget_snapshot(authorized_client, dummy_service):
|
||||
response = api_backup(authorized_client, dummy_service)
|
||||
data = get_data(response)["backup"]["startBackup"]
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 1
|
||||
|
||||
response = api_forget(authorized_client, snaps[0]["id"])
|
||||
data = get_data(response)["backup"]["forgetSnapshot"]
|
||||
assert_ok(data)
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 0
|
||||
|
||||
|
||||
def test_forget_nonexistent_snapshot(authorized_client, dummy_service):
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 0
|
||||
response = api_forget(authorized_client, "898798uekiodpjoiweoiwuoeirueor")
|
||||
data = get_data(response)["backup"]["forgetSnapshot"]
|
||||
assert data["code"] == 404
|
||||
assert data["success"] is False
|
||||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 0
|
||||
|
|
Loading…
Reference in a new issue