generated from john/python-template
test updates
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
"""Tests for the jobs page route."""
|
"""Tests for the jobs page route."""
|
||||||
|
|
||||||
|
from uuid import UUID
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from transcription.ui import register_pages
|
from transcription.ui import register_pages
|
||||||
from transcription.ui.pages import jobs_page
|
from transcription.ui.pages import jobs_page
|
||||||
|
from transcription.ui.pages.jobs_page import JobTableRow
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
@@ -13,7 +16,16 @@ def client(monkeypatch):
|
|||||||
"""Provide a minimal app client with jobs data patched for rendering."""
|
"""Provide a minimal app client with jobs data patched for rendering."""
|
||||||
|
|
||||||
async def _fetch_jobs_stub():
|
async def _fetch_jobs_stub():
|
||||||
return []
|
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)
|
monkeypatch.setattr(jobs_page, "fetch_jobs", _fetch_jobs_stub)
|
||||||
|
|
||||||
@@ -27,11 +39,15 @@ def client(monkeypatch):
|
|||||||
class TestPageRendering:
|
class TestPageRendering:
|
||||||
"""Verify the jobs page is available and includes the main controls."""
|
"""Verify the jobs page is available and includes the main controls."""
|
||||||
|
|
||||||
def test_jobs_page_renders_expected_controls(self, client):
|
def test_jobs_page_renders_expected_controls(self, client, monkeypatch):
|
||||||
"""GET /ui/jobs returns the page shell and jobs controls."""
|
"""GET /ui/jobs returns the page shell and jobs controls."""
|
||||||
response = client.get("/ui/jobs")
|
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 response.status_code == 200
|
||||||
assert "Transcription Jobs" in response.text
|
assert "No jobs yet." in response.text
|
||||||
assert "Refresh" in response.text
|
|
||||||
assert "Back to upload" in response.text
|
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ class TestPageRegistration:
|
|||||||
*,
|
*,
|
||||||
mount_path: str,
|
mount_path: str,
|
||||||
show_welcome_message: bool,
|
show_welcome_message: bool,
|
||||||
|
dark: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
calls.append(f"run_with:{mount_path}:{show_welcome_message}")
|
calls.append(f"run_with:{mount_path}:{show_welcome_message}:{dark}")
|
||||||
|
|
||||||
monkeypatch.setattr("transcription.ui.register_upload_page", _record_upload)
|
monkeypatch.setattr("transcription.ui.register_upload_page", _record_upload)
|
||||||
monkeypatch.setattr("transcription.ui.register_jobs_page", _record_jobs)
|
monkeypatch.setattr("transcription.ui.register_jobs_page", _record_jobs)
|
||||||
@@ -35,4 +36,4 @@ class TestPageRegistration:
|
|||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
register_pages(app)
|
register_pages(app)
|
||||||
|
|
||||||
assert calls == ["upload", "jobs", "run_with:/ui:False"]
|
assert calls == ["upload", "jobs", "run_with:/ui:False:True"]
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ class TestPageRendering:
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert "Upload Document" in response.text
|
assert "Upload Document" in response.text
|
||||||
assert "Select document file" in response.text
|
assert "Select document file" in response.text
|
||||||
assert "View jobs" in response.text
|
assert "Jobs" in response.text
|
||||||
|
|||||||
Reference in New Issue
Block a user