[tracker-miners/wip/carlosg/miner-fs-fixes: 5/5] tests: Add functional test for directory updates updating nfo:belongsToContainer



commit fed0fdcd3680e07b501b43c83583e6ed92522f95
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 19 13:11:17 2020 +0200

    tests: Add functional test for directory updates updating nfo:belongsToContainer
    
    Ensure that relationships witch child nodes is preserved after the
    nformationElement replacement.

 tests/functional-tests/fixtures.py    |  2 +-
 tests/functional-tests/miner-basic.py | 31 +++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/tests/functional-tests/fixtures.py b/tests/functional-tests/fixtures.py
index b48447e33..a226b4b0b 100644
--- a/tests/functional-tests/fixtures.py
+++ b/tests/functional-tests/fixtures.py
@@ -49,7 +49,7 @@ log = logging.getLogger(__name__)
 AUDIO_GRAPH = "http://tracker.api.gnome.org/ontology/v3/tracker#Audio";
 DOCUMENTS_GRAPH = "http://tracker.api.gnome.org/ontology/v3/tracker#Documents";
 PICTURES_GRAPH = "http://tracker.api.gnome.org/ontology/v3/tracker#Pictures";
-
+FILESYSTEM_GRAPH = "http://tracker.api.gnome.org/ontology/v3/tracker#FileSystem";
 
 def tracker_test_main():
     """Entry point which must be called by all functional test modules."""
diff --git a/tests/functional-tests/miner-basic.py b/tests/functional-tests/miner-basic.py
index 86f326800..ecf0adb1f 100755
--- a/tests/functional-tests/miner-basic.py
+++ b/tests/functional-tests/miner-basic.py
@@ -350,6 +350,37 @@ class MinerCrawlTest(fixtures.TrackerMinerTest):
         result = self.__get_text_documents()
         self.assertEqual(len(result), 3)
 
+    def test_10_folder_update(self):
+        """
+        Check that children handle updates on a folder
+        """
+        """
+        The precreated files and folders should be there
+        """
+        print (self.__get_text_documents())
+
+        directory_uri = self.uri("test-monitored")
+        directory = self.path("test-monitored")
+        document = self.path("test-monitored/unrelated.txt")
+        resource_id = self.tracker.get_content_resource_id(directory_uri)
+        urn = self.__get_file_urn(directory)
+
+        with self.await_document_inserted(document) as resource:
+            # Force an update on the monitored folder, it needs both
+            # a explicit request, and an attribute change (obtained
+            # indirectly by the new file)
+            with open(document, 'w') as f:
+                f.write(DEFAULT_TEXT)
+            self.miner_fs.index_file(directory_uri)
+
+        new_urn = self.__get_file_urn(directory)
+        # After the update, the InformationElement should be brand new
+        assert(urn != new_urn)
+        # Ensure that children remain consistent, old and new ones
+        self.assertEqual(new_urn,
+                         self.__get_parent_urn(self.path("test-monitored/file1.txt")))
+        self.assertEqual(self.__get_parent_urn(document),
+                         self.__get_parent_urn(self.path("test-monitored/file1.txt")))
 
 if __name__ == "__main__":
     fixtures.tracker_test_main()


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