mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-24 04:51:27 +00:00
test(backups): test 2-folder restoration
This commit is contained in:
parent
9815281735
commit
d9dab29fe8
|
@ -163,21 +163,31 @@ def test_backup_returns_snapshot(backups, dummy_service):
|
||||||
|
|
||||||
|
|
||||||
def test_restore(backups, dummy_service):
|
def test_restore(backups, dummy_service):
|
||||||
service_folder = dummy_service.get_folders()[0]
|
paths_to_nuke = []
|
||||||
file_to_nuke = listdir(service_folder)[0]
|
contents = []
|
||||||
assert file_to_nuke is not None
|
|
||||||
path_to_nuke = path.join(service_folder, file_to_nuke)
|
for service_folder in dummy_service.get_folders():
|
||||||
|
file_to_nuke = listdir(service_folder)[0]
|
||||||
|
assert file_to_nuke is not None
|
||||||
|
path_to_nuke = path.join(service_folder, file_to_nuke)
|
||||||
|
paths_to_nuke.append(path_to_nuke)
|
||||||
|
with open(path_to_nuke, "r") as file:
|
||||||
|
contents.append(file.read())
|
||||||
|
|
||||||
Backups.back_up(dummy_service)
|
Backups.back_up(dummy_service)
|
||||||
snap = Backups.get_snapshots(dummy_service)[0]
|
snap = Backups.get_snapshots(dummy_service)[0]
|
||||||
assert snap is not None
|
assert snap is not None
|
||||||
|
|
||||||
assert path.exists(path_to_nuke)
|
for p in paths_to_nuke:
|
||||||
remove(path_to_nuke)
|
assert path.exists(p)
|
||||||
assert not path.exists(path_to_nuke)
|
remove(p)
|
||||||
|
assert not path.exists(p)
|
||||||
|
|
||||||
Backups.restore_service_from_snapshot(dummy_service, snap.id)
|
Backups.restore_service_from_snapshot(dummy_service, snap.id)
|
||||||
assert path.exists(path_to_nuke)
|
for p, content in zip(paths_to_nuke, contents):
|
||||||
|
assert path.exists(p)
|
||||||
|
with open(p, "r") as file:
|
||||||
|
assert file.read() == content
|
||||||
|
|
||||||
|
|
||||||
def test_sizing(backups, dummy_service):
|
def test_sizing(backups, dummy_service):
|
||||||
|
@ -381,4 +391,4 @@ def test_services_to_back_up(backups, dummy_service):
|
||||||
|
|
||||||
services = Backups.services_to_back_up(now)
|
services = Backups.services_to_back_up(now)
|
||||||
assert len(services) == 1
|
assert len(services) == 1
|
||||||
assert services[0].get_id() == dummy_service.get_id()
|
assert services[0].get_id() == dummy_service.get_id()
|
||||||
|
|
Loading…
Reference in a new issue