generated from john/python-template
@@ -1,6 +1,7 @@
|
||||
"""Tests for the documents page routes and action handlers."""
|
||||
|
||||
from datetime import date
|
||||
import re
|
||||
|
||||
import pytest
|
||||
import pytest_asyncio
|
||||
@@ -13,6 +14,8 @@ from transcription.db.models import DocumentType
|
||||
from transcription.db.models import Job
|
||||
from transcription.db.models import Person
|
||||
from transcription.db.models import PersonRole
|
||||
from transcription.db.models import Tag
|
||||
from transcription.db.models import DocumentTag
|
||||
from transcription.db.models import Source
|
||||
from transcription.ui.pages.documents_page import _resolve_selected_tag_labels
|
||||
|
||||
@@ -69,12 +72,15 @@ class TestDocumentsPageRendering:
|
||||
|
||||
async with session_scope() as session:
|
||||
postcard_type = (await session.exec(select(DocumentType).where(DocumentType.label == "Postcard"))).one()
|
||||
family_tag = Tag(label="Family", normalized_label="family")
|
||||
doc = Document(
|
||||
name="1924 Postcard",
|
||||
document_type_id=postcard_type.id,
|
||||
archive_identifier="PC-001",
|
||||
)
|
||||
session.add(doc)
|
||||
session.add_all([doc, family_tag])
|
||||
await session.flush()
|
||||
session.add(DocumentTag(document_id=doc.id, tag_id=family_tag.id))
|
||||
await session.commit()
|
||||
|
||||
response = client.get("/ui/documents")
|
||||
@@ -84,8 +90,20 @@ class TestDocumentsPageRendering:
|
||||
assert "Postcard" in response.text
|
||||
assert "Document Date" in response.text
|
||||
assert "Author" in response.text
|
||||
assert "Tags" in response.text
|
||||
assert "Family" in response.text
|
||||
assert "# Sources" in response.text
|
||||
assert "Archive Ref" not in response.text
|
||||
assert re.search(
|
||||
r'"name":"name","label":"Document Title".*'
|
||||
r'"name":"authors","label":"Author".*'
|
||||
r'"name":"tags","label":"Tags".*'
|
||||
r'"name":"document_date","label":"Document Date".*'
|
||||
r'"name":"document_type","label":"Type".*'
|
||||
r'"name":"source_count","label":"# Sources"',
|
||||
response.text,
|
||||
re.DOTALL,
|
||||
)
|
||||
|
||||
def test_document_create_page_renders_form(self, app_client):
|
||||
_, client = app_client
|
||||
|
||||
Reference in New Issue
Block a user