Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheushent committed Jan 14, 2025
1 parent 3ff0c2a commit 9f2eaf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
13 changes: 12 additions & 1 deletion jobbergate-api/jobbergate_api/apps/job_submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
from __future__ import annotations
from datetime import datetime, timezone

from sqlalchemy import ARRAY, Dialect, Enum, ForeignKey, Integer, String, Float, Index, PrimaryKeyConstraint, BigInteger
from sqlalchemy import (
ARRAY,
Dialect,
Enum,
ForeignKey,
Integer,
String,
Float,
Index,
PrimaryKeyConstraint,
BigInteger,
)
from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload
from sqlalchemy.sql.expression import Select
from sqlalchemy.types import DateTime, TypeDecorator
Expand Down
18 changes: 8 additions & 10 deletions jobbergate-api/tests/apps/job_submissions/test_routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2628,7 +2628,7 @@ async def test_job_submissions_metrics__start_time_less_greater_than_end_time(
(Permissions.JOB_SUBMISSIONS_READ, 8),
],
)
async def job_submissions_metrics_timestamps__successful_request(
async def test_job_submissions_metrics_timestamps__successful_request(
permission,
num_rows,
fill_job_script_data,
Expand Down Expand Up @@ -2685,7 +2685,7 @@ async def job_submissions_metrics_timestamps__successful_request(
query = insert(JobSubmissionMetric).values(formatted_data)
await synth_session.execute(query)

inject_security_header("who@cares.com", permission, client_id="dummy-client")
inject_security_header("who@cares.com", permission)
response = await client.get(
f"/jobbergate/job-submissions/{inserted_job_submission_id}/metrics/timestamps"
)
Expand All @@ -2705,18 +2705,19 @@ async def job_submissions_metrics_timestamps__successful_request(
(Permissions.JOB_SUBMISSIONS_READ, 4967),
],
)
async def job_submissions_metrics_timestamps__job_submission_not_found(
async def test_job_submissions_metrics_timestamps__job_submission_not_found(
permission,
job_submission_id,
client,
inject_security_header,
synth_services,
):
"""
Test GET /job-submissions/{job_submission_id}/metrics/timestamps returns 404
when the job submission doesn't exist
"""

inject_security_header("who@cares.com", permission, client_id="dummy-client")
inject_security_header("who@cares.com", permission)
response = await client.get(f"/jobbergate/job-submissions/{job_submission_id}/metrics/timestamps")
assert response.status_code == status.HTTP_404_NOT_FOUND

Expand All @@ -2729,12 +2730,9 @@ async def job_submissions_metrics_timestamps__job_submission_not_found(

@pytest.mark.parametrize(
"permission",
[
(Permissions.ADMIN,),
(Permissions.JOB_SUBMISSIONS_READ,),
],
[Permissions.ADMIN, Permissions.JOB_SUBMISSIONS_READ],
)
async def job_submissions_metrics_timestamps__job_submission_has_no_metric(
async def test_job_submissions_metrics_timestamps__job_submission_has_no_metric(
permission,
fill_job_script_data,
fill_job_submission_data,
Expand Down Expand Up @@ -2770,6 +2768,6 @@ async def job_submissions_metrics_timestamps__job_submission_has_no_metric(

response_data = response.json()
assert (
response_data
response_data["detail"]
== f"No metrics found for job submission {inserted_job_submission_id} or job submission does not exist"
)

0 comments on commit 9f2eaf0

Please sign in to comment.