[tracker] functional tests: Ensure nfo:belongsToContainer is changed on file moves



commit c3df868966586f410f143280955394c616c00b88
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Tue Jan 25 11:10:53 2011 +0100

    functional tests: Ensure nfo:belongsToContainer is changed on file moves

 tests/functional-tests/300-miner-basic-ops.py |   32 +++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/300-miner-basic-ops.py b/tests/functional-tests/300-miner-basic-ops.py
index 7d3abcc..c28df97 100755
--- a/tests/functional-tests/300-miner-basic-ops.py
+++ b/tests/functional-tests/300-miner-basic-ops.py
@@ -44,6 +44,26 @@ class MinerCrawlTest (CommonTrackerMinerTest):
           }
           """)
 
+    def __get_parent_urn (self, filepath):
+        result = self.tracker.query ("""
+          SELECT nfo:belongsToContainer(?u) WHERE {
+              ?u a nfo:FileDataObject ;
+                 nie:url \"%s\" .
+          }
+          """ % (uri (filepath)))
+        self.assertEquals (len (result), 1)
+        return result[0][0]
+
+    def __get_file_urn (self, filepath):
+        result = self.tracker.query ("""
+          SELECT ?u WHERE {
+              ?u a nfo:FileDataObject ;
+                 nie:url \"%s\" .
+          }
+          """ % (uri (filepath)))
+        self.assertEquals (len (result), 1)
+        return result[0][0]
+
     def tearDown (self):
         # Give it a 2 seconds chance
         result = self.__get_text_documents ()
@@ -203,9 +223,21 @@ class MinerCrawlTest (CommonTrackerMinerTest):
         """
         source = os.path.join (BASEDIR, "test-monitored", "dir1", "file2.txt")
         dest = os.path.join (BASEDIR, "test-monitored", "file2.txt")
+
+        source_dir_urn = self.__get_file_urn (os.path.join (BASEDIR, "test-monitored", "dir1"))
+        parent_before = self.__get_parent_urn (source)
+        self.assertEquals (source_dir_urn, parent_before)
+
         shutil.move (source, dest)
         self.system.tracker_miner_fs_wait_for_idle ()
 
+        # Checking fix for NB#214413: After a move operation, nfo:belongsToContainer
+        # should be changed to the new one
+        dest_dir_urn = self.__get_file_urn (os.path.join (BASEDIR, "test-monitored"))
+        parent_after = self.__get_parent_urn (dest)
+        self.assertNotEquals (parent_before, parent_after)
+        self.assertEquals (dest_dir_urn, parent_after)
+
         result = self.__get_text_documents ()
         self.assertEquals (len (result), 3)
         unpacked_result = [ r[0] for r in result]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]