generated from john/python-template
V4.1 Mostly UI adjustments by GC
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
"""Tests for the documents page routes and action handlers."""
|
||||
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from sqlmodel import select
|
||||
|
||||
from transcription.db import session_scope
|
||||
from transcription.db.models import Document, DocumentPerson, DocumentPersonRole, Job, Person, Source
|
||||
|
||||
from transcription.db.models import Document
|
||||
from transcription.db.models import DocumentPerson
|
||||
from transcription.db.models import DocumentPersonRole
|
||||
from transcription.db.models import Job
|
||||
from transcription.db.models import Person
|
||||
from transcription.db.models import Source
|
||||
|
||||
# --- Helper Fixtures ---
|
||||
|
||||
@@ -68,6 +73,8 @@ class TestDocumentsPageRendering:
|
||||
assert "1924 Postcard" in response.text
|
||||
assert "postcard" in response.text
|
||||
assert "PC-001" in response.text
|
||||
assert "Document Date" in response.text
|
||||
assert "Author" in response.text
|
||||
|
||||
def test_document_create_page_renders_form(self, app_client):
|
||||
_, client = app_client
|
||||
@@ -80,6 +87,24 @@ class TestDocumentsPageRendering:
|
||||
assert "Linked People by Role" in response.text
|
||||
assert "Document type" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_document_create_page_preselects_person_with_disambiguating_label(self, app_client):
|
||||
_, client = app_client
|
||||
async with session_scope() as session:
|
||||
person = Person(
|
||||
full_name="Albert Edward Higgins",
|
||||
display_name="Hig",
|
||||
birth_date=date(1885, 1, 2),
|
||||
)
|
||||
session.add(person)
|
||||
await session.commit()
|
||||
person_id = str(person.id)
|
||||
|
||||
response = client.get(f"/ui/documents/new?person_id={person_id}")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "Hig - Albert Edward Higgins (1885)" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_document_detail_page_renders_bento_grid_and_metadata(
|
||||
self, app_client, seed_person_and_document
|
||||
@@ -93,6 +118,8 @@ class TestDocumentsPageRendering:
|
||||
assert "Letter from Hig" in response.text
|
||||
assert "ZC-1924-001" in response.text
|
||||
assert "Zenna Cochran" in response.text
|
||||
assert f"/ui/people/{seed_person_and_document[1]}" in response.text
|
||||
assert "PIPELINE JOBS" in response.text.upper()
|
||||
assert "Edit Document" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -176,4 +203,4 @@ class TestDocumentsPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Delete Document" in response.text
|
||||
assert "Delete document permanently" in response.text
|
||||
assert "Delete is blocked" not in response.text
|
||||
assert "Delete is blocked" not in response.text
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
from datetime import date
|
||||
|
||||
from transcription.db.models import Person
|
||||
from transcription.ui.components.formatters import compact_date
|
||||
from transcription.ui.components.formatters import family_search_url
|
||||
from transcription.ui.components.formatters import person_selector_label
|
||||
|
||||
|
||||
def test_compact_date_prefers_exact_then_approximate_then_unknown():
|
||||
assert compact_date(date(1924, 3, 2), "about 1924") == "1924-03-02"
|
||||
assert compact_date(None, "about 1924") == "about 1924"
|
||||
assert compact_date(None, " ") == "Unknown"
|
||||
|
||||
|
||||
def test_person_selector_label_disambiguates_without_changing_identity():
|
||||
person = Person(
|
||||
full_name="Albert Edward Higgins",
|
||||
display_name="Hig",
|
||||
birth_date=date(1885, 1, 2),
|
||||
)
|
||||
assert person_selector_label(person) == "Hig - Albert Edward Higgins (1885)"
|
||||
|
||||
approximate = Person(
|
||||
full_name="Albert Edward Higgins",
|
||||
display_name="Hig",
|
||||
birth_date_raw="about 1912",
|
||||
)
|
||||
assert person_selector_label(approximate) == "Hig - Albert Edward Higgins (1912)"
|
||||
|
||||
|
||||
def test_family_search_url_uses_fixed_person_details_route():
|
||||
assert family_search_url("G8T4-MDQ") == (
|
||||
"https://www.familysearch.org/tree/person/details/G8T4-MDQ"
|
||||
)
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
from sqlmodel import select
|
||||
|
||||
from transcription.db import session_scope
|
||||
from transcription.db.models import Document, Job, JobSourceStatus, JobStatus
|
||||
|
||||
from transcription.db.models import Document
|
||||
from transcription.db.models import Job
|
||||
from transcription.db.models import JobStatus
|
||||
|
||||
# --- Helper Fixtures ---
|
||||
|
||||
@@ -99,6 +99,7 @@ class TestJobsPageRendering:
|
||||
assert "gpt-4o" in response.text
|
||||
assert "View Linked Document" in response.text
|
||||
assert "View Linked Sources" in response.text
|
||||
assert "updates automatically while the job is active" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_job_cancel_page_renders_confirmation(
|
||||
@@ -164,4 +165,4 @@ class TestJobsPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Delete Processing Job" in response.text
|
||||
assert "Delete job permanently" in response.text
|
||||
assert "Delete is blocked" not in response.text
|
||||
assert "Delete is blocked" not in response.text
|
||||
|
||||
@@ -6,7 +6,10 @@ from uuid import uuid4
|
||||
import pytest
|
||||
|
||||
from transcription.db import session_scope
|
||||
from transcription.db.models import Document, DocumentPerson, DocumentPersonRole, Person
|
||||
from transcription.db.models import Document
|
||||
from transcription.db.models import DocumentPerson
|
||||
from transcription.db.models import DocumentPersonRole
|
||||
from transcription.db.models import Person
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@@ -47,6 +50,7 @@ class TestPeoplePageRendering:
|
||||
assert "Full name is required." in response.text
|
||||
assert "Birth date (YYYY-MM-DD)" in response.text
|
||||
assert "Death date (YYYY-MM-DD)" in response.text
|
||||
assert "FamilySearch ID" in response.text
|
||||
assert "Biography" in response.text
|
||||
assert "Save person" in response.text
|
||||
|
||||
@@ -67,6 +71,7 @@ class TestPeoplePageRendering:
|
||||
death_place="Arlington",
|
||||
biography="Computer pioneer",
|
||||
portrait_path="/images/grace.jpg",
|
||||
family_search_id="G8T4-MDQ",
|
||||
)
|
||||
session.add(person)
|
||||
await session.commit()
|
||||
@@ -87,6 +92,9 @@ class TestPeoplePageRendering:
|
||||
assert "Computer pioneer" in response.text
|
||||
assert "Created:" in response.text
|
||||
assert "Updated:" in response.text
|
||||
assert "Open in FamilySearch" in response.text
|
||||
assert "familysearch.org/tree/person/details/G8T4-MDQ" in response.text
|
||||
assert "New Document" in response.text
|
||||
assert "No linked documents yet." in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -182,4 +190,4 @@ class TestPeoplePageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "Delete Person Record" in response.text
|
||||
assert "This action permanently deletes the person record." in response.text
|
||||
assert "Delete person permanently" in response.text
|
||||
assert "Delete person permanently" in response.text
|
||||
|
||||
@@ -4,11 +4,13 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from sqlmodel import select
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||
|
||||
from transcription.db import session_scope
|
||||
from transcription.db.models import Document, Job, JobSourceStatus, JobStatus, Source
|
||||
|
||||
from transcription.db.models import Document
|
||||
from transcription.db.models import Job
|
||||
from transcription.db.models import JobSourceStatus
|
||||
from transcription.db.models import JobStatus
|
||||
from transcription.db.models import Source
|
||||
|
||||
# --- Unit Tests for Model @property Definitions ---
|
||||
|
||||
@@ -99,6 +101,7 @@ class TestSourcesPageRendering:
|
||||
assert response.status_code == 200
|
||||
assert "page_one.png" in response.text
|
||||
assert "Source Document" in response.text
|
||||
assert "Stored Filename" not in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sources_page_filters_to_document_context(self, app_client):
|
||||
@@ -211,6 +214,8 @@ class TestSourcesPageRendering:
|
||||
assert "original transcription text" in response.text
|
||||
assert "human revision text" in response.text
|
||||
assert "Save revision" in response.text
|
||||
assert "Previous Page" in response.text
|
||||
assert "Next Page" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_source_delete_page_blocks_when_source_is_job_linked(
|
||||
|
||||
Reference in New Issue
Block a user