generated from john/python-template
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""Tests for the jobs page route."""
|
|
|
|
from uuid import UUID
|
|
|
|
import pytest
|
|
from fastapi import FastAPI
|
|
from fastapi.testclient import TestClient
|
|
|
|
from transcription.ui import register_pages
|
|
from transcription.ui.pages import jobs_page
|
|
from transcription.ui.pages.jobs_page import JobTableRow
|
|
|
|
|
|
@pytest.fixture
|
|
def client(monkeypatch):
|
|
"""Provide a minimal app client with jobs data patched for rendering."""
|
|
|
|
async def _fetch_jobs_stub():
|
|
return [
|
|
JobTableRow(
|
|
id=UUID("00000000-0000-0000-0000-000000000001"),
|
|
status="queued",
|
|
filename="sample.pdf",
|
|
retry_count=2,
|
|
created_at="2026-01-01T12:00:00+00:00",
|
|
updated_at="2026-01-01T12:01:00+00:00",
|
|
)
|
|
]
|
|
|
|
monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_stub)
|
|
|
|
app = FastAPI()
|
|
register_pages(app)
|
|
with TestClient(app) as test_client:
|
|
yield test_client
|
|
|
|
|
|
@pytest.mark.integration
|
|
class TestPageRendering:
|
|
"""Verify the jobs page is available and includes the main controls."""
|
|
|
|
def test_jobs_page_renders_expected_controls(self, client, monkeypatch):
|
|
"""GET /ui/jobs returns the page shell and jobs controls."""
|
|
response = client.get("/ui/jobs")
|
|
|
|
async def _fetch_jobs_empty():
|
|
return []
|
|
|
|
monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_empty)
|
|
response = client.get("/ui/jobs")
|
|
|
|
assert response.status_code == 200
|
|
assert "No jobs yet." in response.text
|