Fix: let documents without an owner use every OCR template

Unowned documents only matched unowned templates, so they never matched
templates created in the UI. Consider every template, as matching does.
This commit is contained in:
stumpylog committed 2026-11-19 08:43:29 -08:00
1 parent 0117fed721
commit 0f4a71ed88
2 files changed
+25 -11

No files matched your search

+15 -4
View File
@@ -1534,22 +1534,33 @@ class TestTemplateVisibility:
assert private in get_templates_for_document(document)
@pytest.mark.usefixtures("mine", "private")
def test_unowned_documents_only_use_unowned_templates(
def test_unowned_documents_consider_every_template(
self,
other: User,
document: Document,
mine: OcrTemplate,
unowned: OcrTemplate,
private: OcrTemplate,
) -> None:
"""
GIVEN:
- A document with no owner
- Templates owned by two users and an unowned template
WHEN:
- Templates are selected for the document
- Templates are selected for consumption, and for a manual run by
one of the users
THEN:
- Only unowned templates apply
- Consumption considers every template
- The manual run is limited to templates the requester can view
"""
document.owner = None
assert get_templates_for_document(document) == [unowned]
assert Counter(get_templates_for_document(document)) == Counter(
[mine, unowned, private],
)
assert Counter(
get_templates_for_document(document, requester=other),
) == Counter([unowned, private])
@pytest.mark.usefixtures("private")
def test_versions_use_the_root_documents_owner(