mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-17 08:02:36 +00:00
fix(backup): make last slice return a correct list
This commit is contained in:
parent
a5b52c8f75
commit
b67777835d
|
@ -118,7 +118,7 @@ def do_autobackup() -> None:
|
|||
|
||||
|
||||
def eligible_for_full_restoration(snap: Snapshot):
|
||||
service = ServiceManager.get_service_by_id(Snapshot.service_name)
|
||||
service = ServiceManager.get_service_by_id(snap.service_name)
|
||||
if service is None:
|
||||
return False
|
||||
if service.is_enabled() is False:
|
||||
|
|
|
@ -102,4 +102,4 @@ class Backup:
|
|||
def last_slice(self) -> typing.List[SnapshotInfo]:
|
||||
if not Backups.is_initted():
|
||||
return []
|
||||
result = [snapshot_to_api(snap) for snap in which_snapshots_to_full_restore()]
|
||||
return [snapshot_to_api(snap) for snap in which_snapshots_to_full_restore()]
|
||||
|
|
|
@ -161,6 +161,18 @@ mutation TestForgetSnapshot($snapshot_id: String!) {
|
|||
}
|
||||
"""
|
||||
|
||||
API_LAST_SLICE_QUERY = """
|
||||
lastSlice {
|
||||
id
|
||||
service {
|
||||
id
|
||||
displayName
|
||||
}
|
||||
createdAt
|
||||
reason
|
||||
}
|
||||
"""
|
||||
|
||||
API_SNAPSHOTS_QUERY = """
|
||||
allSnapshots {
|
||||
id
|
||||
|
@ -349,6 +361,17 @@ def api_snapshots(authorized_client):
|
|||
return result
|
||||
|
||||
|
||||
def api_last_slice(authorized_client):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
json={"query": generate_backup_query([API_LAST_SLICE_QUERY])},
|
||||
)
|
||||
data = get_data(response)
|
||||
result = data["backup"]["lastSlice"]
|
||||
assert result is not None
|
||||
return result
|
||||
|
||||
|
||||
def api_settings(authorized_client):
|
||||
response = authorized_client.post(
|
||||
"/graphql",
|
||||
|
@ -633,3 +656,10 @@ def test_forget_nonexistent_snapshot(authorized_client, dummy_service, backups):
|
|||
|
||||
snaps = api_snapshots(authorized_client)
|
||||
assert len(snaps) == 0
|
||||
|
||||
|
||||
def test_last_slice(authorized_client, only_dummy_service_and_api, backups):
|
||||
api_manual_autobackup(authorized_client)
|
||||
snaps = api_last_slice(authorized_client)
|
||||
|
||||
assert len(snaps) == 2
|
||||
|
|
Loading…
Reference in a new issue