-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from aldbr/main_FEAT_routers-split-job-tests
chore(routers): split test_job_manager
- Loading branch information
Showing
5 changed files
with
1,861 additions
and
1,836 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
|
||
TEST_JDL = """ | ||
Arguments = "jobDescription.xml -o LogLevel=INFO"; | ||
Executable = "dirac-jobexec"; | ||
JobGroup = jobGroup; | ||
JobName = jobName; | ||
JobType = User; | ||
LogLevel = INFO; | ||
OutputSandbox = | ||
{ | ||
Script1_CodeOutput.log, | ||
std.err, | ||
std.out | ||
}; | ||
Priority = 1; | ||
Site = ANY; | ||
StdError = std.err; | ||
StdOutput = std.out; | ||
""" | ||
|
||
TEST_PARAMETRIC_JDL = """ | ||
Arguments = "jobDescription.xml -o LogLevel=DEBUG -p JOB_ID=%(JOB_ID)s -p InputData=%(InputData)s"; | ||
Executable = "dirac-jobexec"; | ||
InputData = %(InputData)s; | ||
InputSandbox = jobDescription.xml; | ||
JOB_ID = %(JOB_ID)s; | ||
JobName = Name; | ||
JobType = User; | ||
LogLevel = DEBUG; | ||
OutputSandbox = | ||
{ | ||
Script1_CodeOutput.log, | ||
std.err, | ||
std.out | ||
}; | ||
Parameters = 3; | ||
Parameters.InputData = | ||
{ | ||
{/lhcb/data/data1, | ||
/lhcb/data/data2}, | ||
{/lhcb/data/data3, | ||
/lhcb/data/data4}, | ||
{/lhcb/data/data5, | ||
/lhcb/data/data6} | ||
}; | ||
Parameters.JOB_ID = | ||
{ | ||
1, | ||
2, | ||
3 | ||
}; | ||
Priority = 1; | ||
StdError = std.err; | ||
StdOutput = std.out; | ||
""" | ||
|
||
|
||
@pytest.fixture | ||
def normal_user_client(client_factory): | ||
with client_factory.normal_user() as client: | ||
yield client | ||
|
||
|
||
@pytest.fixture | ||
def admin_user_client(client_factory): | ||
with client_factory.admin_user() as client: | ||
yield client | ||
|
||
|
||
@pytest.fixture | ||
def valid_job_id(normal_user_client: TestClient): | ||
job_definitions = [TEST_JDL] | ||
r = normal_user_client.post("/api/jobs/jdl", json=job_definitions) | ||
assert r.status_code == 200, r.json() | ||
assert len(r.json()) == 1 | ||
return r.json()[0]["JobID"] | ||
|
||
|
||
@pytest.fixture | ||
def valid_job_ids(normal_user_client: TestClient): | ||
job_definitions = [TEST_PARAMETRIC_JDL] | ||
r = normal_user_client.post("/api/jobs/jdl", json=job_definitions) | ||
assert r.status_code == 200, r.json() | ||
assert len(r.json()) == 3 | ||
return sorted([job_dict["JobID"] for job_dict in r.json()]) | ||
|
||
|
||
@pytest.fixture | ||
def invalid_job_id(): | ||
return 999999996 | ||
|
||
|
||
@pytest.fixture | ||
def invalid_job_ids(): | ||
return [999999997, 999999998, 999999999] |
Oops, something went wrong.