From 728ea44823c42ee2d46cf344f8e56ab6323cb0fa Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Fri, 29 Sep 2023 12:30:44 +0000 Subject: [PATCH] test(service): startstop --- tests/test_graphql/test_services.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/test_graphql/test_services.py b/tests/test_graphql/test_services.py index 93fe682..ea1f272 100644 --- a/tests/test_graphql/test_services.py +++ b/tests/test_graphql/test_services.py @@ -61,7 +61,7 @@ allServices { """ -def api_start(client, service): +def api_start(client, service: Service): response = client.post( "/graphql", json={ @@ -72,7 +72,7 @@ def api_start(client, service): return response -def api_stop(client, service): +def api_stop(client, service: Service): response = client.post( "/graphql", json={ @@ -108,3 +108,28 @@ 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 + + +def test_stop_start(authorized_client, only_dummy_service): + dummy_service = only_dummy_service + + api_dummy_service = api_all_services(authorized_client)[0] + assert api_dummy_service["status"] == ServiceStatus.ACTIVE.value + + # attempting to start an already started service + api_start(authorized_client, dummy_service) + api_dummy_service = api_all_services(authorized_client)[0] + assert api_dummy_service["status"] == ServiceStatus.ACTIVE.value + + api_stop(authorized_client, dummy_service) + api_dummy_service = api_all_services(authorized_client)[0] + assert api_dummy_service["status"] == ServiceStatus.INACTIVE.value + + # attempting to stop an already stopped service + api_stop(authorized_client, dummy_service) + api_dummy_service = api_all_services(authorized_client)[0] + assert api_dummy_service["status"] == ServiceStatus.INACTIVE.value + + api_start(authorized_client, dummy_service) + api_dummy_service = api_all_services(authorized_client)[0] + assert api_dummy_service["status"] == ServiceStatus.ACTIVE.value