mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-16 07:33:16 +00:00
test(service): enabled status get
This commit is contained in:
parent
728ea44823
commit
92612906ef
|
@ -30,9 +30,10 @@ class DummyService(Service):
|
|||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
status_file = self.status_file()
|
||||
with open(status_file, "w") as file:
|
||||
with open(self.status_file(), "w") as file:
|
||||
file.write(ServiceStatus.ACTIVE.value)
|
||||
with open(self.enabled_file(), "w") as file:
|
||||
file.write("True")
|
||||
|
||||
@staticmethod
|
||||
def get_id() -> str:
|
||||
|
@ -83,6 +84,26 @@ class DummyService(Service):
|
|||
# we do not REALLY want to store our state in our declared folders
|
||||
return path.join(dir, "..", "service_status")
|
||||
|
||||
@classmethod
|
||||
def enabled_file(cls) -> str:
|
||||
dir = cls.folders[0]
|
||||
return path.join(dir, "..", "service_enabled")
|
||||
|
||||
@classmethod
|
||||
def get_enabled(cls) -> bool:
|
||||
with open(cls.enabled_file(), "r") as file:
|
||||
string = file.read().strip()
|
||||
if "True" in string:
|
||||
return True
|
||||
if "False" in string:
|
||||
return False
|
||||
raise ValueError("test service enabled/disabled status file got corrupted")
|
||||
|
||||
@classmethod
|
||||
def set_enabled(cls, enabled: bool):
|
||||
with open(cls.enabled_file(), "w") as file:
|
||||
status_string = file.write(str(enabled))
|
||||
|
||||
@classmethod
|
||||
def set_status(cls, status: ServiceStatus):
|
||||
with open(cls.status_file(), "w") as file:
|
||||
|
|
|
@ -57,6 +57,7 @@ API_SERVICES_QUERY = """
|
|||
allServices {
|
||||
id
|
||||
status
|
||||
isEnabled
|
||||
}
|
||||
"""
|
||||
|
||||
|
@ -108,6 +109,7 @@ def test_get_services(authorized_client, only_dummy_service):
|
|||
api_dummy_service = services[0]
|
||||
assert api_dummy_service["id"] == "testservice"
|
||||
assert api_dummy_service["status"] == ServiceStatus.ACTIVE.value
|
||||
assert api_dummy_service["isEnabled"] is True
|
||||
|
||||
|
||||
def test_stop_start(authorized_client, only_dummy_service):
|
||||
|
|
Loading…
Reference in a new issue