Skip to content

Commit 226a224

Browse files
committed
chore(routers): split test_job_manager
1 parent 36dc88a commit 226a224

File tree

5 files changed

+1860
-1836
lines changed

5 files changed

+1860
-1836
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from __future__ import annotations
2+
3+
import pytest
4+
from fastapi.testclient import TestClient
5+
6+
TEST_JDL = """
7+
Arguments = "jobDescription.xml -o LogLevel=INFO";
8+
Executable = "dirac-jobexec";
9+
JobGroup = jobGroup;
10+
JobName = jobName;
11+
JobType = User;
12+
LogLevel = INFO;
13+
OutputSandbox =
14+
{
15+
Script1_CodeOutput.log,
16+
std.err,
17+
std.out
18+
};
19+
Priority = 1;
20+
Site = ANY;
21+
StdError = std.err;
22+
StdOutput = std.out;
23+
"""
24+
25+
TEST_PARAMETRIC_JDL = """
26+
Arguments = "jobDescription.xml -o LogLevel=DEBUG -p JOB_ID=%(JOB_ID)s -p InputData=%(InputData)s";
27+
Executable = "dirac-jobexec";
28+
InputData = %(InputData)s;
29+
InputSandbox = jobDescription.xml;
30+
JOB_ID = %(JOB_ID)s;
31+
JobName = Name;
32+
JobType = User;
33+
LogLevel = DEBUG;
34+
OutputSandbox =
35+
{
36+
Script1_CodeOutput.log,
37+
std.err,
38+
std.out
39+
};
40+
Parameters = 3;
41+
Parameters.InputData =
42+
{
43+
{/lhcb/data/data1,
44+
/lhcb/data/data2},
45+
{/lhcb/data/data3,
46+
/lhcb/data/data4},
47+
{/lhcb/data/data5,
48+
/lhcb/data/data6}
49+
};
50+
Parameters.JOB_ID =
51+
{
52+
1,
53+
2,
54+
3
55+
};
56+
Priority = 1;
57+
StdError = std.err;
58+
StdOutput = std.out;
59+
"""
60+
61+
62+
@pytest.fixture
63+
def normal_user_client(client_factory):
64+
with client_factory.normal_user() as client:
65+
yield client
66+
67+
68+
@pytest.fixture
69+
def admin_user_client(client_factory):
70+
with client_factory.admin_user() as client:
71+
yield client
72+
73+
74+
@pytest.fixture
75+
def valid_job_id(normal_user_client: TestClient):
76+
job_definitions = [TEST_JDL]
77+
r = normal_user_client.post("/api/jobs/jdl", json=job_definitions)
78+
assert r.status_code == 200, r.json()
79+
assert len(r.json()) == 1
80+
return r.json()[0]["JobID"]
81+
82+
83+
@pytest.fixture
84+
def valid_job_ids(normal_user_client: TestClient):
85+
job_definitions = [TEST_PARAMETRIC_JDL]
86+
r = normal_user_client.post("/api/jobs/jdl", json=job_definitions)
87+
assert r.status_code == 200, r.json()
88+
assert len(r.json()) == 3
89+
return sorted([job_dict["JobID"] for job_dict in r.json()])
90+
91+
92+
@pytest.fixture
93+
def invalid_job_id():
94+
return 999999996
95+
96+
97+
@pytest.fixture
98+
def invalid_job_ids():
99+
return [999999997, 999999998, 999999999]

0 commit comments

Comments
 (0)