From 6f5e47970ed48335aa23979bcf15b0ffa61604cb Mon Sep 17 00:00:00 2001 From: Ryunosuke O'Neil Date: Sun, 15 Dec 2024 03:22:39 +0100 Subject: [PATCH] more fun with tests --- diracx-routers/tests/test_job_manager.py | 1 + .../tests/test_gubbins_job_manager.py | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/diracx-routers/tests/test_job_manager.py b/diracx-routers/tests/test_job_manager.py index 5145eb30..2acb14f7 100644 --- a/diracx-routers/tests/test_job_manager.py +++ b/diracx-routers/tests/test_job_manager.py @@ -365,6 +365,7 @@ def test_user_cannot_submit_multiple_jdl_if_at_least_one_of_them_is_parametric( def test_user_without_the_normal_user_property_cannot_submit_job(admin_user_client): + pytest.skip("AlwaysAllowAccessPolicyCallable is forced in testing, so this test can not actually test this access policy.") res = admin_user_client.post("/api/jobs/jdl", json=[TEST_JDL]) assert res.status_code == HTTPStatus.FORBIDDEN, res.json() diff --git a/extensions/gubbins/gubbins-routers/tests/test_gubbins_job_manager.py b/extensions/gubbins/gubbins-routers/tests/test_gubbins_job_manager.py index e70d926c..cfe23a7f 100644 --- a/extensions/gubbins/gubbins-routers/tests/test_gubbins_job_manager.py +++ b/extensions/gubbins/gubbins-routers/tests/test_gubbins_job_manager.py @@ -71,16 +71,30 @@ def test_gubbins_job_router(normal_user_client, valid_job_id): """ # We search for the job - r = normal_user_client.get(f"/api/jobs/{valid_job_id}/status") + r = normal_user_client.post( + "/api/jobs/search", + json={ + "search": [{"parameter": "JobID", "operator": "eq", "value": valid_job_id}], + }, + ) assert r.status_code == 200, r.json() - assert r.json()[str(valid_job_id)]["Status"] == JobStatus.RECEIVED + assert r.json()[0]["JobID"] == valid_job_id + assert r.json()[0]["Status"] == JobStatus.RECEIVED # We delete the job, and here we expect that nothing # actually happened - r = normal_user_client.delete(f"/api/jobs/{valid_job_id}") + r = normal_user_client.delete(f"/api/jobs/", params={ + "job_ids": [valid_job_id], + }) assert r.status_code == 200, r.json() - r = normal_user_client.get(f"/api/jobs/{valid_job_id}/status") + r = normal_user_client.post( + "/api/jobs/search", + json={ + "search": [{"parameter": "JobID", "operator": "eq", "value": valid_job_id}], + }, + ) assert r.status_code == 200, r.json() # The job would normally be deleted - assert r.json()[str(valid_job_id)]["Status"] == JobStatus.RECEIVED + assert r.json()[0]["JobID"] == valid_job_id + assert r.json()[0]["Status"] == JobStatus.RECEIVED