From 9cc6e304c0ff91140f20cf147a37296152384410 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 9 Jan 2023 15:29:43 +0000 Subject: [PATCH] test(tokens-repo): remove device order dependence from graphql test__api --- tests/test_graphql/common.py | 4 ++++ tests/test_graphql/test_api.py | 20 ++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/tests/test_graphql/common.py b/tests/test_graphql/common.py index 03f48b7..d473433 100644 --- a/tests/test_graphql/common.py +++ b/tests/test_graphql/common.py @@ -75,6 +75,10 @@ def assert_same(graphql_devices, abstract_devices): def assert_original(client): devices = graphql_get_devices(client) + assert_original_devices(devices) + + +def assert_original_devices(devices): assert_same(devices, ORIGINAL_DEVICES) for device in devices: diff --git a/tests/test_graphql/test_api.py b/tests/test_graphql/test_api.py index 695dd8e..c252d44 100644 --- a/tests/test_graphql/test_api.py +++ b/tests/test_graphql/test_api.py @@ -3,6 +3,7 @@ # pylint: disable=missing-function-docstring from tests.common import generate_api_query +from tests.test_graphql.common import assert_original_devices from tests.test_graphql.test_api_devices import API_DEVICES_QUERY from tests.test_graphql.test_api_recovery import API_RECOVERY_QUERY from tests.test_graphql.test_api_version import API_VERSION_QUERY @@ -20,20 +21,11 @@ def test_graphql_get_entire_api_data(authorized_client, tokens_file): assert response.status_code == 200 assert response.json().get("data") is not None assert "version" in response.json()["data"]["api"] - assert response.json()["data"]["api"]["devices"] is not None - assert len(response.json()["data"]["api"]["devices"]) == 2 - assert ( - response.json()["data"]["api"]["devices"][0]["creationDate"] - == "2022-01-14T08:31:10.789314" - ) - assert response.json()["data"]["api"]["devices"][0]["isCaller"] is True - assert response.json()["data"]["api"]["devices"][0]["name"] == "test_token" - assert ( - response.json()["data"]["api"]["devices"][1]["creationDate"] - == "2022-01-14T08:31:10.789314" - ) - assert response.json()["data"]["api"]["devices"][1]["isCaller"] is False - assert response.json()["data"]["api"]["devices"][1]["name"] == "test_token2" + + devices = response.json()["data"]["api"]["devices"] + assert devices is not None + assert_original_devices(devices) + assert response.json()["data"]["api"]["recoveryKey"] is not None assert response.json()["data"]["api"]["recoveryKey"]["exists"] is False assert response.json()["data"]["api"]["recoveryKey"]["valid"] is False