mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-29 23:41:28 +00:00
test(backups): make delay settable per dummyservice
This commit is contained in:
parent
e7a6700522
commit
713296c520
|
@ -23,6 +23,7 @@ class DummyService(Service):
|
||||||
"""A test service"""
|
"""A test service"""
|
||||||
|
|
||||||
folders: List[str] = []
|
folders: List[str] = []
|
||||||
|
startstop_delay = 0
|
||||||
|
|
||||||
def __init_subclass__(cls, folders: List[str]):
|
def __init_subclass__(cls, folders: List[str]):
|
||||||
cls.folders = folders
|
cls.folders = folders
|
||||||
|
@ -119,19 +120,23 @@ class DummyService(Service):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def stop(cls, delay=DEFAULT_DELAY):
|
def set_delay(cls, new_delay):
|
||||||
|
cls.startstop_delay = new_delay
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def stop(cls):
|
||||||
cls.set_status(ServiceStatus.DEACTIVATING)
|
cls.set_status(ServiceStatus.DEACTIVATING)
|
||||||
cls.change_status_with_async_delay(ServiceStatus.INACTIVE, delay)
|
cls.change_status_with_async_delay(ServiceStatus.INACTIVE, cls.startstop_delay)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def start(cls, delay=DEFAULT_DELAY):
|
def start(cls):
|
||||||
cls.set_status(ServiceStatus.ACTIVATING)
|
cls.set_status(ServiceStatus.ACTIVATING)
|
||||||
cls.change_status_with_async_delay(ServiceStatus.ACTIVE, delay)
|
cls.change_status_with_async_delay(ServiceStatus.ACTIVE, cls.startstop_delay)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def restart(cls, delay=DEFAULT_DELAY):
|
def restart(cls):
|
||||||
cls.set_status(ServiceStatus.RELOADING) # is a correct one?
|
cls.set_status(ServiceStatus.RELOADING) # is a correct one?
|
||||||
cls.change_status_with_async_delay(ServiceStatus.ACTIVE, delay)
|
cls.change_status_with_async_delay(ServiceStatus.ACTIVE, cls.startstop_delay)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_configuration():
|
def get_configuration():
|
||||||
|
|
|
@ -30,13 +30,14 @@ def test_unimplemented_folders_raises():
|
||||||
|
|
||||||
def test_delayed_start_stop(raw_dummy_service):
|
def test_delayed_start_stop(raw_dummy_service):
|
||||||
dummy = raw_dummy_service
|
dummy = raw_dummy_service
|
||||||
|
dummy.set_delay(0.3)
|
||||||
|
|
||||||
dummy.stop(delay=0.3)
|
dummy.stop()
|
||||||
assert dummy.get_status() == ServiceStatus.DEACTIVATING
|
assert dummy.get_status() == ServiceStatus.DEACTIVATING
|
||||||
wait_until_true(lambda: dummy.get_status() == ServiceStatus.INACTIVE)
|
wait_until_true(lambda: dummy.get_status() == ServiceStatus.INACTIVE)
|
||||||
assert dummy.get_status() == ServiceStatus.INACTIVE
|
assert dummy.get_status() == ServiceStatus.INACTIVE
|
||||||
|
|
||||||
dummy.start(delay=0.3)
|
dummy.start()
|
||||||
assert dummy.get_status() == ServiceStatus.ACTIVATING
|
assert dummy.get_status() == ServiceStatus.ACTIVATING
|
||||||
wait_until_true(lambda: dummy.get_status() == ServiceStatus.ACTIVE)
|
wait_until_true(lambda: dummy.get_status() == ServiceStatus.ACTIVE)
|
||||||
assert dummy.get_status() == ServiceStatus.ACTIVE
|
assert dummy.get_status() == ServiceStatus.ACTIVE
|
||||||
|
|
Loading…
Reference in a new issue