mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-16 15:43:16 +00:00
7935de0fe1
Co-authored-by: inexcode <inex.code@selfprivacy.org> Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api/pulls/13
58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
# pylint: disable=redefined-outer-name
|
|
# pylint: disable=unused-argument
|
|
# pylint: disable=missing-function-docstring
|
|
|
|
from tests.common import generate_api_query
|
|
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
|
|
|
|
TOKENS_FILE_CONTETS = {
|
|
"tokens": [
|
|
{
|
|
"token": "TEST_TOKEN",
|
|
"name": "test_token",
|
|
"date": "2022-01-14 08:31:10.789314",
|
|
},
|
|
{
|
|
"token": "TEST_TOKEN2",
|
|
"name": "test_token2",
|
|
"date": "2022-01-14 08:31:10.789314",
|
|
},
|
|
]
|
|
}
|
|
|
|
|
|
def test_graphql_get_entire_api_data(authorized_client, tokens_file):
|
|
response = authorized_client.post(
|
|
"/graphql",
|
|
json={
|
|
"query": generate_api_query(
|
|
[API_VERSION_QUERY, API_DEVICES_QUERY, API_RECOVERY_QUERY]
|
|
)
|
|
},
|
|
)
|
|
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"
|
|
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
|
|
assert response.json()["data"]["api"]["recoveryKey"]["creationDate"] is None
|
|
assert response.json()["data"]["api"]["recoveryKey"]["expirationDate"] is None
|
|
assert response.json()["data"]["api"]["recoveryKey"]["usesLeft"] is None
|