From 4b0a0058be7effb57b1033ae26faefad1ac2a9bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Calonne?= <aurel@nexedi.com>
Date: Fri, 9 Nov 2007 09:10:45 +0000
Subject: [PATCH] test that when we reindex an object in an archive, it goes
 only in the archive

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17483 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Catalog/tests/testArchive.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/product/ERP5Catalog/tests/testArchive.py b/product/ERP5Catalog/tests/testArchive.py
index 8a13f2320c..0d3867f948 100644
--- a/product/ERP5Catalog/tests/testArchive.py
+++ b/product/ERP5Catalog/tests/testArchive.py
@@ -280,6 +280,8 @@ class TestArchive(InventoryAPITestCase):
     self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.archive_connection_id)
 
     # Create a new movement and check it goes only in new catalog
+    import pdb
+    pdb.set_trace()
     self.assertEqual(len(self.folder.searchFolder(portal_type="Dummy Movement")), 0)
     self.assertEquals(100, getInventory(node_uid=self.node.getUid()))
     self.new_mvt = self._makeMovement(quantity=50, stop_date=DateTime("2006/08/06"),
@@ -319,6 +321,25 @@ class TestArchive(InventoryAPITestCase):
     # As we only have first movement in archive, inventory must be 100
     self.assertEquals(100, getInventory(node=self.node.getRelativeUrl()))
 
+    # go on current catalog
+    self.pref.edit(preferred_archive=None)
+    get_transaction().commit()
+    self.tic()
+
+    # unindex and reindex an older movement and check it's well reindexed    
+    self.inventory.unindexObject()
+    get_transaction().commit()
+    self.tic()
+    path_list = [self.inventory.getRelativeUrl()]
+    self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.new_connection_id)
+    self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.archive_connection_id)
+    self.inventory.reindexObject()
+    get_transaction().commit()
+    self.tic()
+    path_list = [self.inventory.getRelativeUrl()]
+    self.checkRelativeUrlNotInSQLPathList(path_list, connection_id=self.new_connection_id)
+    self.checkRelativeUrlInSQLPathList(path_list, connection_id=self.archive_connection_id)
+
 
 def test_suite():
   suite = unittest.TestSuite()
-- 
2.30.9