mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-09-16 21:55:37 -05:00
Use json str, normalize keys
This commit is contained in:
@@ -1758,6 +1758,8 @@ class PostDocumentSerializer(serializers.Serializer):
|
|||||||
"value": value,
|
"value": value,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
# Normalize keys to integers for later
|
||||||
|
return {int(k): v for k, v in custom_fields_w_values.items()}
|
||||||
|
|
||||||
def validate_created(self, created):
|
def validate_created(self, created):
|
||||||
# support datetime format for created for backwards compatibility
|
# support datetime format for created for backwards compatibility
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import uuid
|
import uuid
|
||||||
@@ -1551,7 +1552,10 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
|||||||
with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f:
|
with (Path(__file__).parent / "samples" / "simple.pdf").open("rb") as f:
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
"/api/documents/post_document/",
|
"/api/documents/post_document/",
|
||||||
{"document": f, "custom_fields_w_values": {"3456": "a string"}},
|
{
|
||||||
|
"document": f,
|
||||||
|
"custom_fields_w_values": json.dumps({"3456": "a string"}),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
|
||||||
self.consume_file_mock.assert_not_called()
|
self.consume_file_mock.assert_not_called()
|
||||||
@@ -1571,10 +1575,12 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
|||||||
"/api/documents/post_document/",
|
"/api/documents/post_document/",
|
||||||
{
|
{
|
||||||
"document": f,
|
"document": f,
|
||||||
"custom_fields_w_values": {
|
"custom_fields_w_values": json.dumps(
|
||||||
|
{
|
||||||
str(cf_string.id): "a string",
|
str(cf_string.id): "a string",
|
||||||
str(cf_int.id): 123,
|
str(cf_int.id): 123,
|
||||||
},
|
},
|
||||||
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user