From 2d9f48650e398e72c6b22d13b0327da28e13fb26 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 15 May 2024 13:42:17 +0000 Subject: [PATCH] test(jobs) test API job format --- tests/test_graphql/test_jobs.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/test_graphql/test_jobs.py b/tests/test_graphql/test_jobs.py index 8dfb102..68a6d20 100644 --- a/tests/test_graphql/test_jobs.py +++ b/tests/test_graphql/test_jobs.py @@ -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