mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-05-03 11:29:28 -05:00
A couple more test fixes
This commit is contained in:
parent
a47c1b98c4
commit
12953eb022
@ -657,13 +657,16 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
|
|||||||
name="Test Custom Field Select",
|
name="Test Custom Field Select",
|
||||||
data_type=CustomField.FieldDataType.SELECT,
|
data_type=CustomField.FieldDataType.SELECT,
|
||||||
extra_data={
|
extra_data={
|
||||||
"select_options": ["Option 1", "Choice 2"],
|
"select_options": [
|
||||||
|
{"label": "Option 1", "id": "abc123"},
|
||||||
|
{"label": "Choice 2", "id": "def456"},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
CustomFieldInstance.objects.create(
|
CustomFieldInstance.objects.create(
|
||||||
document=doc1,
|
document=doc1,
|
||||||
field=custom_field_select,
|
field=custom_field_select,
|
||||||
value_select=1,
|
value_select="def456",
|
||||||
)
|
)
|
||||||
|
|
||||||
r = self.client.get("/api/documents/?custom_fields__icontains=choice")
|
r = self.client.get("/api/documents/?custom_fields__icontains=choice")
|
||||||
|
@ -528,9 +528,9 @@ class TestCustomFieldsSearch(DirectoriesMixin, APITestCase):
|
|||||||
|
|
||||||
def test_invalid_value(self):
|
def test_invalid_value(self):
|
||||||
self._assert_validation_error(
|
self._assert_validation_error(
|
||||||
json.dumps(["select_field", "exact", "not an option"]),
|
json.dumps(["select_field", "exact", []]),
|
||||||
["custom_field_query", "2"],
|
["custom_field_query", "2"],
|
||||||
"integer",
|
"string",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_invalid_logical_operator(self):
|
def test_invalid_logical_operator(self):
|
||||||
|
@ -544,7 +544,11 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
name="test",
|
name="test",
|
||||||
data_type=CustomField.FieldDataType.SELECT,
|
data_type=CustomField.FieldDataType.SELECT,
|
||||||
extra_data={
|
extra_data={
|
||||||
"select_options": ["apple", "banana", "cherry"],
|
"select_options": [
|
||||||
|
{"label": "apple", "id": "abc123"},
|
||||||
|
{"label": "banana", "id": "def456"},
|
||||||
|
{"label": "cherry", "id": "ghi789"},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
doc = Document.objects.create(
|
doc = Document.objects.create(
|
||||||
@ -555,14 +559,22 @@ class TestFileHandling(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
|
|||||||
archive_checksum="B",
|
archive_checksum="B",
|
||||||
mime_type="application/pdf",
|
mime_type="application/pdf",
|
||||||
)
|
)
|
||||||
CustomFieldInstance.objects.create(field=cf, document=doc, value_select=0)
|
CustomFieldInstance.objects.create(
|
||||||
|
field=cf,
|
||||||
|
document=doc,
|
||||||
|
value_select="abc123",
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(generate_filename(doc), "document_apple.pdf")
|
self.assertEqual(generate_filename(doc), "document_apple.pdf")
|
||||||
|
|
||||||
# handler should not have been called
|
# handler should not have been called
|
||||||
self.assertEqual(m.call_count, 0)
|
self.assertEqual(m.call_count, 0)
|
||||||
cf.extra_data = {
|
cf.extra_data = {
|
||||||
"select_options": ["aubergine", "banana", "cherry"],
|
"select_options": [
|
||||||
|
{"label": "aubergine", "id": "abc123"},
|
||||||
|
{"label": "banana", "id": "def456"},
|
||||||
|
{"label": "cherry", "id": "ghi789"},
|
||||||
|
],
|
||||||
}
|
}
|
||||||
cf.save()
|
cf.save()
|
||||||
self.assertEqual(generate_filename(doc), "document_aubergine.pdf")
|
self.assertEqual(generate_filename(doc), "document_aubergine.pdf")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user