IndexTestCase.test_dual_level_dual_document_index failure
On my test system (Debian with a Postgresql 10 DB, both running in Docker containers using Mayan 3.1.9) the IndexTestCase.test_dual_level_dual_document_index
test case fails.
The test creates a dual-level document index and then compares the index nodes against a list.
On my system the order of the nodes for the two documents is in the wrong order - i.e. the nodes for self.document
appear before the nodes for self.document_2
.
The test is:
class IndexTestCase(DocumentIndexingTestMixin, DocumentTestMixin, BaseTestCase):
def test_dual_level_dual_document_index(self):
"""
Test creation of an index instance with two first levels with different
values and two second levels with the same value but as separate
children of each of the first levels. GitLab issue #391
"""
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
self.document_2 = self.document_type.new_document(
file_object=file_object
)
self._create_index()
# Create simple index template
root = self.index.template_root
level_1 = self.index.node_templates.create(
parent=root, expression='{{ document.uuid }}',
link_documents=False
)
self.index.node_templates.create(
parent=level_1, expression='{{ document.label }}',
link_documents=True
)
Index.objects.rebuild()
self.assertEqual(
[instance.value for instance in IndexInstanceNode.objects.all().order_by('pk')],
[
'', force_text(self.document_2.uuid), self.document_2.label,
force_text(self.document.uuid), self.document.label
]
)
It seems to me that Index.objects.rebuild()
doesn't specify the order that the documents will be indexed in, so you can't be sure that the index nodes for self.document_2
will be created before the nodes for self.document
and therefore have lower primary key values.
Have I missed something?