[tracker/sam/functional-test-fixes: 24/28] functional-tests/310-fts-indexing: Further fixes



commit f8696f5533eed68b61c495944e0056e7ca2e6d4b
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Aug 2 03:14:01 2014 +0100

    functional-tests/310-fts-indexing: Further fixes
    
    Need to wait for a property update rather than resource insertion
    when overwriting an existing file.
    
    I also removed a pointless time.sleep() call.
    
    A couple of tests still fail. Possibly these are due to actual bugs.

 tests/functional-tests/310-fts-indexing.py |   25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/tests/functional-tests/310-fts-indexing.py b/tests/functional-tests/310-fts-indexing.py
index 33e2adf..e2a2167 100755
--- a/tests/functional-tests/310-fts-indexing.py
+++ b/tests/functional-tests/310-fts-indexing.py
@@ -55,12 +55,18 @@ class CommonMinerFTS (CommonTrackerMinerTest):
         pass
 
     def set_text (self, text):
-        f = open (path (self.testfile), "w")
-        f.write (text)
-        f.close ()
-        self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
-                                              url = uri (self.testfile),
-                                              required_property = 'nie:plainTextContent')
+        file_existed = os.path.exists(path(self.testfile))
+
+        with open(path (self.testfile), "w") as f:
+            f.write (text)
+
+        if file_existed:
+            resource_id = self.tracker.get_resource_id(uri(self.testfile))
+            self.tracker.await_property_changed (resource_id, 'nie:plainTextContent')
+        else:
+            self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
+                                                url = uri (self.testfile),
+                                                required_property = 'nie:plainTextContent')
         self.tracker.reset_graph_updates_tracking ()
 
     def search_word (self, word):
@@ -209,6 +215,8 @@ class MinerFTSFileOperationsTest (CommonMinerFTS):
     def test_03_update_the_file (self):
         """
         Changing the contents of the file, updates the index
+
+        FIXME: this test currently fails.
         """
         TEXT = "automobile is red and big and whatnot"
         self.basic_test (TEXT, "automobile")
@@ -256,15 +264,14 @@ class MinerFTSFileOperationsTest (CommonMinerFTS):
         TEST_16_DEST = "test-monitored/fts-indexing-text-16.txt"
         
         self.__recreate_file (path (TEST_16_SOURCE), TEXT)
-        # the file is supposed to be ignored by tracker, so there is no notification..
-        time.sleep (5)
 
         results = self.search_word ("airplane")
         self.assertEquals (len (results), 0)
 
         shutil.copyfile ( path (TEST_16_SOURCE), path (TEST_16_DEST))
         self.tracker.await_resource_inserted (rdf_class = 'nfo:Document',
-                                              url = uri (TEST_16_DEST))
+                                              url = uri (TEST_16_DEST),
+                                              required_property = 'nie:plainTextContent')
 
         results = self.search_word ("airplane")
         self.assertEquals (len (results), 1)


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