generated from john/python-template
V4.3 revision to Document Types
This commit is contained in:
@@ -4,11 +4,13 @@ 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
|
||||
from transcription.db.models import DocumentPerson
|
||||
from transcription.db.models import DocumentPersonRole
|
||||
from transcription.db.models import DocumentType
|
||||
from transcription.db.models import Job
|
||||
from transcription.db.models import Person
|
||||
from transcription.db.models import Source
|
||||
@@ -20,13 +22,14 @@ from transcription.db.models import Source
|
||||
async def seed_person_and_document():
|
||||
"""Seed a Person and Document linked by DocumentPerson role."""
|
||||
async with session_scope() as session:
|
||||
letter_type = (await session.exec(select(DocumentType).where(DocumentType.label == "Letter"))).one()
|
||||
person = Person(full_name="Zenna Cochran")
|
||||
session.add(person)
|
||||
await session.flush()
|
||||
|
||||
doc = Document(
|
||||
name="Letter from Hig",
|
||||
document_type="letter",
|
||||
document_type_id=letter_type.id,
|
||||
archive_identifier="ZC-1924-001",
|
||||
)
|
||||
session.add(doc)
|
||||
@@ -63,7 +66,12 @@ class TestDocumentsPageRendering:
|
||||
_, client = app_client
|
||||
|
||||
async with session_scope() as session:
|
||||
doc = Document(name="1924 Postcard", document_type="postcard", archive_identifier="PC-001")
|
||||
postcard_type = (await session.exec(select(DocumentType).where(DocumentType.label == "Postcard"))).one()
|
||||
doc = Document(
|
||||
name="1924 Postcard",
|
||||
document_type_id=postcard_type.id,
|
||||
archive_identifier="PC-001",
|
||||
)
|
||||
session.add(doc)
|
||||
await session.commit()
|
||||
|
||||
@@ -71,7 +79,7 @@ class TestDocumentsPageRendering:
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "1924 Postcard" in response.text
|
||||
assert "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
|
||||
@@ -106,9 +114,7 @@ class TestDocumentsPageRendering:
|
||||
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
|
||||
):
|
||||
async def test_document_detail_page_renders_bento_grid_and_metadata(self, app_client, seed_person_and_document):
|
||||
_, client = app_client
|
||||
doc_id, _ = seed_person_and_document
|
||||
|
||||
@@ -143,9 +149,7 @@ class TestDocumentsPageRendering:
|
||||
assert f"Job ID: {job_id}" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_document_edit_page_prefills_existing_values(
|
||||
self, app_client, seed_person_and_document
|
||||
):
|
||||
async def test_document_edit_page_prefills_existing_values(self, app_client, seed_person_and_document):
|
||||
_, client = app_client
|
||||
doc_id, _ = seed_person_and_document
|
||||
|
||||
@@ -157,9 +161,7 @@ class TestDocumentsPageRendering:
|
||||
assert "ZC-1924-001" in response.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_document_delete_page_blocks_deletion_when_dependencies_exist(
|
||||
self, app_client
|
||||
):
|
||||
async def test_document_delete_page_blocks_deletion_when_dependencies_exist(self, app_client):
|
||||
_, client = app_client
|
||||
|
||||
async with session_scope() as session:
|
||||
|
||||
Reference in New Issue
Block a user