From bda4959f93d3569a0755da2750d85d922049defd Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Fri, 20 Nov 2026 14:34:16 -0800 Subject: [PATCH] Chore: test combine formats on a template created without zones --- src/documents/tests/test_api_ocr_templates.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/documents/tests/test_api_ocr_templates.py b/src/documents/tests/test_api_ocr_templates.py index 84b905fb78..79b37a129c 100644 --- a/src/documents/tests/test_api_ocr_templates.py +++ b/src/documents/tests/test_api_ocr_templates.py @@ -1324,6 +1324,27 @@ class TestOcrTemplateValidation: ) assert response.status_code == status.HTTP_400_BAD_REQUEST + def test_combine_formats_create_without_zones_is_rejected( + self, + admin_client: APIClient, + ) -> None: + """ + GIVEN: + - No saved template and a create payload with no zones key + WHEN: + - Create is attempted with a combine format + THEN: + - The combine format has no zone targets to match and is rejected + on combine_formats + """ + payload = template_payload(combine_formats={"title": "{A}"}) + del payload["zones"] + + response = admin_client.post(ENDPOINT, payload, format="json") + + assert response.status_code == status.HTTP_400_BAD_REQUEST + assert "combine_formats" in response.json() + @pytest.mark.django_db @pytest.mark.usefixtures("paperless_dirs")