test(jobs) test API job format

This commit is contained in:
Houkime 2024-05-15 13:42:17 +00:00
parent 1fadf0214b
commit 4306c94231

View file

@ -1,4 +1,6 @@
from tests.common import generate_jobs_query
import tests.test_graphql.test_api_backup
from tests.test_graphql.common import (
assert_ok,
assert_empty,
@ -6,6 +8,8 @@ from tests.test_graphql.common import (
get_data,
)
from selfprivacy_api.jobs import Jobs
API_JOBS_QUERY = """
getJobs {
uid
@ -46,3 +50,25 @@ def test_all_jobs_unauthorized(client):
def test_all_jobs_when_none(authorized_client):
output = api_jobs(authorized_client)
assert output == []
def test_all_jobs_when_some(authorized_client):
# We cannot make new jobs via API, at least directly
job = Jobs.add("bogus", "bogus.bogus", "fungus")
output = api_jobs(authorized_client)
len(output) == 1
api_job = output[0]
assert api_job["uid"] == str(job.uid)
assert api_job["typeId"] == job.type_id
assert api_job["name"] == job.name
assert api_job["description"] == job.description
assert api_job["status"] == job.status
assert api_job["statusText"] == job.status_text
assert api_job["progress"] == job.progress
assert api_job["createdAt"] == job.created_at.isoformat()
assert api_job["updatedAt"] == job.updated_at.isoformat()
assert api_job["finishedAt"] == None
assert api_job["error"] == None
assert api_job["result"] == None