From 47cfaad160b817ed2c3d92467e3c85938b2c6687 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Fri, 29 Sep 2023 13:46:22 +0000 Subject: [PATCH] test(service): startstop return values --- tests/test_graphql/test_services.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/test_graphql/test_services.py b/tests/test_graphql/test_services.py index efd86d8..85090cf 100644 --- a/tests/test_graphql/test_services.py +++ b/tests/test_graphql/test_services.py @@ -7,7 +7,7 @@ from selfprivacy_api.services.service import Service, ServiceStatus import tests.test_graphql.test_api_backup from tests.test_common import raw_dummy_service, dummy_service from tests.common import generate_service_query -from tests.test_graphql.common import get_data +from tests.test_graphql.common import assert_ok, get_data @pytest.fixture() @@ -62,7 +62,7 @@ allServices { """ -def api_start(client, service: Service): +def api_start(client, service: Service) -> dict: response = client.post( "/graphql", json={ @@ -73,7 +73,7 @@ def api_start(client, service: Service): return response -def api_stop(client, service: Service): +def api_stop(client, service: Service) -> dict: response = client.post( "/graphql", json={ @@ -112,6 +112,26 @@ def test_get_services(authorized_client, only_dummy_service): assert api_dummy_service["isEnabled"] is True +def test_start_return_value(authorized_client, only_dummy_service): + dummy_service = only_dummy_service + mutation_response = api_start(authorized_client, dummy_service) + data = get_data(mutation_response)["services"]["startService"] + assert_ok(data) + service = data["service"] + assert service["id"] == dummy_service.get_id() + assert service["status"] == ServiceStatus.ACTIVE.value + + +def test_stop_return_value(authorized_client, only_dummy_service): + dummy_service = only_dummy_service + mutation_response = api_stop(authorized_client, dummy_service) + data = get_data(mutation_response)["services"]["stopService"] + assert_ok(data) + service = data["service"] + assert service["id"] == dummy_service.get_id() + assert service["status"] == ServiceStatus.INACTIVE.value + + def test_stop_start(authorized_client, only_dummy_service): dummy_service = only_dummy_service