From f82bb44540197468e492ae720d19996ef16e2462 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 5 Jan 2015 14:10:50 -0400 Subject: [PATCH] Don't remove the root instance node, there is no aparent side effect but is unnecessary --- mayan/apps/document_indexing/api.py | 3 +-- mayan/apps/document_indexing/tests.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/mayan/apps/document_indexing/api.py b/mayan/apps/document_indexing/api.py index a0c0c46004..b282c43b12 100644 --- a/mayan/apps/document_indexing/api.py +++ b/mayan/apps/document_indexing/api.py @@ -76,11 +76,10 @@ def delete_empty_index_nodes(): Delete empty index instance nodes """ - for instance_node in IndexInstanceNode.objects.filter(documents__isnull=True): + for instance_node in IndexInstanceNode.objects.filter(documents__isnull=True, parent__isnull=False): task_delete_empty_index_nodes_recursive(instance_node) - def task_delete_empty_index_nodes_recursive(instance_node): """ Calls itself recursively deleting empty index instance nodes up to root diff --git a/mayan/apps/document_indexing/tests.py b/mayan/apps/document_indexing/tests.py index 32ffb5f928..9925e71b8a 100644 --- a/mayan/apps/document_indexing/tests.py +++ b/mayan/apps/document_indexing/tests.py @@ -65,12 +65,12 @@ class IndexTestCase(TestCase): # Check node instance is destoyed when no metadata is available self.document.metadata.get(metadata_type=metadata_type).delete() - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), []) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'']) # Add document metadata value again to trigger index node instance creation self.document.metadata.create(metadata_type=metadata_type, value='0003') self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u'', u'0003']) - # Check node instance is destoyed when no documents are contained + # Check node instance is destroyed when no documents are contained self.document.delete() - self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), []) + self.failUnlessEqual(list(IndexInstanceNode.objects.values_list('value', flat=True)), [u''])