mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-02-16 22:34:32 +00:00
test(tokens-repo): break out assert_data()
This commit is contained in:
parent
5a1b48fa3d
commit
4676e364a6
|
@ -34,9 +34,8 @@ def graphql_get_devices(client):
|
||||||
"/graphql",
|
"/graphql",
|
||||||
json={"query": generate_api_query([API_DEVICES_QUERY])},
|
json={"query": generate_api_query([API_DEVICES_QUERY])},
|
||||||
)
|
)
|
||||||
assert response.status_code == 200
|
data = assert_data(response)
|
||||||
assert response.json().get("data") is not None
|
devices = data["api"]["devices"]
|
||||||
devices = response.json()["data"]["api"]["devices"]
|
|
||||||
assert devices is not None
|
assert devices is not None
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
|
@ -63,19 +62,17 @@ def assert_original(client):
|
||||||
|
|
||||||
|
|
||||||
def assert_ok(response, request):
|
def assert_ok(response, request):
|
||||||
assert response.status_code == 200
|
data = assert_data(response)
|
||||||
assert response.json().get("data") is not None
|
data[request]["success"] is True
|
||||||
assert response.json()["data"][request]["success"] is True
|
data[request]["message"] is not None
|
||||||
assert response.json()["data"][request]["message"] is not None
|
data[request]["code"] == 200
|
||||||
assert response.json()["data"][request]["code"] == 200
|
|
||||||
|
|
||||||
|
|
||||||
def assert_errorcode(response, request, code):
|
def assert_errorcode(response, request, code):
|
||||||
assert response.status_code == 200
|
data = assert_data(response)
|
||||||
assert response.json().get("data") is not None
|
data[request]["success"] is False
|
||||||
assert response.json()["data"][request]["success"] is False
|
data[request]["message"] is not None
|
||||||
assert response.json()["data"][request]["message"] is not None
|
data[request]["code"] == code
|
||||||
assert response.json()["data"][request]["code"] == code
|
|
||||||
|
|
||||||
|
|
||||||
def assert_empty(response):
|
def assert_empty(response):
|
||||||
|
@ -83,6 +80,13 @@ def assert_empty(response):
|
||||||
assert response.json().get("data") is None
|
assert response.json().get("data") is None
|
||||||
|
|
||||||
|
|
||||||
|
def assert_data(response):
|
||||||
|
assert response.status_code == 200
|
||||||
|
data = response.json().get("data")
|
||||||
|
assert data is not None
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_tokens_info(authorized_client, tokens_file):
|
def test_graphql_tokens_info(authorized_client, tokens_file):
|
||||||
assert_original(authorized_client)
|
assert_original(authorized_client)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue