From 5a8b47067301e8aa2899365e9121d568637a7b53 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 14 Sep 2025 19:47:57 -0700 Subject: [PATCH] Add negative test --- src/documents/tests/test_api_documents.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py index ebdafeb4c..d4eadeec1 100644 --- a/src/documents/tests/test_api_documents.py +++ b/src/documents/tests/test_api_documents.py @@ -1547,6 +1547,16 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase): id=str(uuid.uuid4()), ) + # invalid custom field ids + with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f: + response = self.client.post( + "/api/documents/post_document/", + {"document": f, "custom_fields_w_values": {"3456": "a string"}}, + ) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.consume_file_mock.assert_not_called() + self.consume_file_mock.reset_mock() + cf_string = CustomField.objects.create( name="stringfield", data_type=CustomField.FieldDataType.STRING,