2025-11-05 17:01:33 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2025-11-05 18:45:13 +01:00
|
|
|
from uuid import UUID, uuid4
|
|
|
|
|
|
2025-11-05 17:01:33 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from dataloader.api.v1.exceptions import JobNotFoundError
|
2025-11-05 18:45:13 +01:00
|
|
|
from dataloader.api.v1.router import cancel_job, get_status
|
2025-11-05 17:01:33 +01:00
|
|
|
from dataloader.api.v1.schemas import JobStatusResponse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _FakeSvc:
|
|
|
|
|
async def status(self, job_id: UUID) -> JobStatusResponse | None:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
async def cancel(self, job_id: UUID) -> JobStatusResponse | None:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.unit
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_router_get_status_raises_job_not_found():
|
|
|
|
|
svc = _FakeSvc()
|
|
|
|
|
with pytest.raises(JobNotFoundError):
|
|
|
|
|
await get_status(uuid4(), svc=svc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.unit
|
|
|
|
|
@pytest.mark.asyncio
|
|
|
|
|
async def test_router_cancel_raises_job_not_found():
|
|
|
|
|
svc = _FakeSvc()
|
|
|
|
|
with pytest.raises(JobNotFoundError):
|
|
|
|
|
await cancel_job(uuid4(), svc=svc)
|