mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
test(jobs): test Graphql job getting
This commit is contained in:
parent
63d2e48a98
commit
c4aa757ca4
|
@ -69,6 +69,10 @@ def generate_backup_query(query_array):
|
||||||
return "query TestBackup {\n backup {" + "\n".join(query_array) + "}\n}"
|
return "query TestBackup {\n backup {" + "\n".join(query_array) + "}\n}"
|
||||||
|
|
||||||
|
|
||||||
|
def generate_jobs_query(query_array):
|
||||||
|
return "query TestJobs {\n jobs {" + "\n".join(query_array) + "}\n}"
|
||||||
|
|
||||||
|
|
||||||
def generate_service_query(query_array):
|
def generate_service_query(query_array):
|
||||||
return "query TestService {\n services {" + "\n".join(query_array) + "}\n}"
|
return "query TestService {\n services {" + "\n".join(query_array) + "}\n}"
|
||||||
|
|
||||||
|
|
48
tests/test_graphql/test_jobs.py
Normal file
48
tests/test_graphql/test_jobs.py
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
from tests.common import generate_jobs_query
|
||||||
|
from tests.test_graphql.common import (
|
||||||
|
assert_ok,
|
||||||
|
assert_empty,
|
||||||
|
assert_errorcode,
|
||||||
|
get_data,
|
||||||
|
)
|
||||||
|
|
||||||
|
API_JOBS_QUERY = """
|
||||||
|
getJobs {
|
||||||
|
uid
|
||||||
|
typeId
|
||||||
|
name
|
||||||
|
description
|
||||||
|
status
|
||||||
|
statusText
|
||||||
|
progress
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
finishedAt
|
||||||
|
error
|
||||||
|
result
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def graphql_send_query(client, query: str, variables: dict = {}):
|
||||||
|
return client.post("/graphql", json={"query": query, "variables": variables})
|
||||||
|
|
||||||
|
|
||||||
|
def api_jobs(authorized_client):
|
||||||
|
response = graphql_send_query(
|
||||||
|
authorized_client, generate_jobs_query([API_JOBS_QUERY])
|
||||||
|
)
|
||||||
|
data = get_data(response)
|
||||||
|
result = data["jobs"]["getJobs"]
|
||||||
|
assert result is not None
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def test_all_jobs_unauthorized(client):
|
||||||
|
response = graphql_send_query(client, generate_jobs_query([API_JOBS_QUERY]))
|
||||||
|
assert_empty(response)
|
||||||
|
|
||||||
|
|
||||||
|
def test_all_jobs_when_none(authorized_client):
|
||||||
|
output = api_jobs(authorized_client)
|
||||||
|
assert output == []
|
Loading…
Reference in a new issue