mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
test(backups): register dummy service
This commit is contained in:
parent
1940b29161
commit
6132f1bb4c
|
@ -57,7 +57,6 @@ class Backups:
|
|||
services = Storage.services_with_autobackup()
|
||||
return [id for id in services if Backups.is_time_to_backup_service(id, time)]
|
||||
|
||||
# untestable until the dummy service is registered
|
||||
@staticmethod
|
||||
def services_to_back_up(time: datetime) -> List[Service]:
|
||||
result = []
|
||||
|
@ -243,7 +242,6 @@ class Backups:
|
|||
|
||||
Backups.provider().backuper.restore_from_backup(repo_name, snapshot_id, folder)
|
||||
|
||||
# Our dummy service is not yet globally registered so this is not testable yet
|
||||
@staticmethod
|
||||
def restore_snapshot(snapshot: Snapshot):
|
||||
Backups.restore_service_from_snapshot(
|
||||
|
@ -255,7 +253,6 @@ class Backups:
|
|||
repo_name = service.get_id()
|
||||
return Backups.provider().backuper.restored_size(repo_name, snapshot_id)
|
||||
|
||||
# Our dummy service is not yet globally registered so this is not testable yet
|
||||
@staticmethod
|
||||
def snapshot_restored_size(snapshot: Snapshot) -> float:
|
||||
return Backups.service_snapshot_size(
|
||||
|
|
|
@ -5,6 +5,8 @@ from os import remove
|
|||
from os import listdir
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import selfprivacy_api.services as services
|
||||
from selfprivacy_api.services import get_service_by_id
|
||||
from selfprivacy_api.services.test_service import DummyService
|
||||
from selfprivacy_api.graphql.queries.providers import BackupProvider
|
||||
|
||||
|
@ -58,6 +60,11 @@ def dummy_service(tmpdir, backups, raw_dummy_service):
|
|||
# assert not repo_path
|
||||
|
||||
Backups.init_repo(service)
|
||||
|
||||
# register our service
|
||||
services.services.append(service)
|
||||
|
||||
assert get_service_by_id(service.get_id()) is not None
|
||||
return service
|
||||
|
||||
|
||||
|
@ -354,3 +361,15 @@ def test_provider_storage(backups_backblaze):
|
|||
assert isinstance(restored_provider, Backblaze)
|
||||
assert restored_provider.login == "ID"
|
||||
assert restored_provider.key == "KEY"
|
||||
|
||||
|
||||
def test_services_to_back_up(backups, dummy_service):
|
||||
backup_period = 13 # minutes
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
Backups.enable_autobackup(dummy_service)
|
||||
Backups.set_autobackup_period_minutes(backup_period)
|
||||
|
||||
services = Backups.services_to_back_up(now)
|
||||
assert len(services) == 1
|
||||
assert services[0].get_id() == dummy_service.get_id()
|
Loading…
Reference in a new issue