Skip to content

Commit 6f62d2e

Browse files
author
Robin VAN DE MERGHEL
committed
fix: Minor fixes, and testing pilot summary
1 parent f5e52c2 commit 6f62d2e

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

diracx-logic/src/diracx/logic/pilots/management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def register_new_pilots(
2424
status: str,
2525
pilot_job_references: dict[str, str] | None,
2626
):
27-
# [IMPORTANT] Check unicity of pilot references
27+
# [IMPORTANT] Check unicity of pilot stamps
2828
# If a pilot already exists, we raise an error (transaction will rollback)
2929
existing_pilots = await get_pilots_by_stamp(
3030
pilot_db=pilot_db, pilot_stamps=pilot_stamps

diracx-routers/src/diracx/routers/pilots/management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ async def update_pilot_fields(
208208

209209
# Prevent someone who stole a pilot X509 to modify thousands of pilots at a time
210210
# (It would be still able to modify thousands of pilots, but slower)
211-
# We are not able to affirm that this pilots modifies itself
211+
# We are not able to affirm that this pilot modifies itself
212212
if GENERIC_PILOT in user_info.properties:
213213
if len(pilot_stamps) != 1:
214214
raise HTTPException(

diracx-routers/src/diracx/routers/pilots/query.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ async def summary(
156156
check_permissions: CheckPilotManagementPolicyCallable,
157157
):
158158
"""Show information suitable for plotting."""
159-
# TODO: Test me.
160159
await check_permissions(action=ActionType.READ_PILOT_FIELDS)
161160

162161
return await summary_bl(

diracx-routers/tests/pilots/test_query.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import pytest
6+
from fastapi.testclient import TestClient
67

78
from diracx.core.exceptions import InvalidQueryError
89
from diracx.core.models import (
@@ -82,6 +83,48 @@ async def populated_pilot_client(normal_test_client):
8283
yield normal_test_client
8384

8485

86+
async def test_pilot_summary(populated_pilot_client: TestClient):
87+
# Group by StatusReason
88+
r = populated_pilot_client.post(
89+
"/api/pilots/summary",
90+
json={
91+
"grouping": ["StatusReason"],
92+
},
93+
)
94+
95+
assert r.status_code == 200
96+
97+
assert sum([el["count"] for el in r.json()]) == N
98+
assert len(r.json()) == len(PILOT_REASONS)
99+
100+
# Group by CurrentJobID
101+
r = populated_pilot_client.post(
102+
"/api/pilots/summary",
103+
json={
104+
"grouping": ["CurrentJobID"],
105+
},
106+
)
107+
108+
assert r.status_code == 200
109+
110+
assert all(el["count"] == 1 for el in r.json())
111+
assert len(r.json()) == N
112+
113+
# Group by CurrentJobID where BenchMark < 10^2
114+
r = populated_pilot_client.post(
115+
"/api/pilots/summary",
116+
json={
117+
"grouping": ["CurrentJobID"],
118+
"search": [{"parameter": "BenchMark", "operator": "lt", "value": 10**2}],
119+
},
120+
)
121+
122+
assert r.status_code == 200, r.json()
123+
124+
assert all(el["count"] == 1 for el in r.json())
125+
assert len(r.json()) == 10
126+
127+
85128
@pytest.fixture
86129
async def search(populated_pilot_client):
87130
async def _search(

0 commit comments

Comments
 (0)