make test_list_jobs_populated deterministic
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -17,19 +17,22 @@ def test_list_jobs_empty(client):
|
|||||||
|
|
||||||
def test_list_jobs_populated(client, db_session):
|
def test_list_jobs_populated(client, db_session):
|
||||||
"""Tests listing jobs with pagination and latest_log inclusion."""
|
"""Tests listing jobs with pagination and latest_log inclusion."""
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
job1 = models.Job(
|
job1 = models.Job(
|
||||||
job_type="SCAN",
|
job_type="SCAN",
|
||||||
status="COMPLETED",
|
status="COMPLETED",
|
||||||
progress=100.0,
|
progress=100.0,
|
||||||
current_task="Done",
|
current_task="Done",
|
||||||
started_at=datetime.now(timezone.utc),
|
started_at=now - timedelta(seconds=2),
|
||||||
completed_at=datetime.now(timezone.utc),
|
completed_at=now - timedelta(seconds=1),
|
||||||
|
created_at=now - timedelta(seconds=2),
|
||||||
)
|
)
|
||||||
job2 = models.Job(
|
job2 = models.Job(
|
||||||
job_type="BACKUP",
|
job_type="BACKUP",
|
||||||
status="RUNNING",
|
status="RUNNING",
|
||||||
progress=50.0,
|
progress=50.0,
|
||||||
current_task="Writing archive",
|
current_task="Writing archive",
|
||||||
|
created_at=now,
|
||||||
)
|
)
|
||||||
db_session.add_all([job1, job2])
|
db_session.add_all([job1, job2])
|
||||||
db_session.flush()
|
db_session.flush()
|
||||||
|
|||||||
Reference in New Issue
Block a user