diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-18 18:01:15 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-18 18:01:15 +0100 |
commit | c1628bd91a7864d526c4f23aeaa801390b62482c (patch) | |
tree | d9490199faba5920aeac7d5a65f81a52f252d56c /archaeological_operations/tests.py | |
parent | ee7fc010ac934c017fc1396d566d139755980f17 (diff) | |
download | Ishtar-c1628bd91a7864d526c4f23aeaa801390b62482c.tar.bz2 Ishtar-c1628bd91a7864d526c4f23aeaa801390b62482c.zip |
Manage index and external id for documents
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r-- | archaeological_operations/tests.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index f8925f610..956afcaaa 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -43,7 +43,8 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \ Town, ImporterColumn, Person, Author, SourceType, AuthorType, \ DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \ JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField, \ - UserProfile, ProfileType, Area, CustomFormJsonField, get_current_profile + UserProfile, ProfileType, Area, CustomFormJsonField, get_current_profile, \ + Document from archaeological_files.models import File, FileType from archaeological_context_records.models import Unit, ContextRecord @@ -1306,6 +1307,26 @@ class OperationTest(TestCase, OperationInitTest): for key in ('32303', 'red', 'Red'): self.assertNotIn(key, operation.search_vector) + def test_document(self): + operation = self.operations[0] + q = Document.objects.values('index').order_by('-index') + if q.count(): + c_index = q.all()[0]['index'] + else: + c_index = 0 + doc = Document.objects.create(title="Image!") + operation.documents.add(doc) + operation.save() + + doc = Document.objects.get(pk=doc.pk) + self.assertEqual(c_index + 1, doc.index) + self.assertEqual(doc.external_id, unicode(doc.index)) + + doc2 = Document.objects.create(title="Image2!") + operation.documents.add(doc2) + doc2 = Document.objects.get(pk=doc2.pk) + self.assertEqual(c_index + 2, doc2.index) + class CustomFormTest(TestCase, OperationInitTest): fixtures = FILE_FIXTURES |