[tracker-miners: 2/3] cli.py, fixtures.py : Added tests added tests for tracker search --folders <exp>




commit 975ac04d061b7d2e022a1c3f56b213904b0e529b
Author: nis130 <nishitlimbani130 gmail com>
Date:   Sun Jan 10 16:33:54 2021 +0530

    cli.py, fixtures.py : Added tests
    added tests for tracker search --folders <exp>

 tests/functional-tests/cli.py      | 12 ++++++++++++
 tests/functional-tests/fixtures.py |  9 +++++++++
 2 files changed, 21 insertions(+)
---
diff --git a/tests/functional-tests/cli.py b/tests/functional-tests/cli.py
index 32fda7033..2153cfc17 100644
--- a/tests/functional-tests/cli.py
+++ b/tests/functional-tests/cli.py
@@ -44,6 +44,14 @@ class TestCli(fixtures.TrackerCommandLineTestCase):
         with self.await_document_inserted(target2):
             shutil.copy(file2, self.indexed_dir)
 
+        folder_name = "test-folder"
+        folder_path = pathlib.Path(os.path.join(self.indexed_dir, folder_name))
+        with self.await_insert_dir(folder_path):
+            try:
+                os.mkdir(os.path.join(self.indexed_dir, folder_name))
+            except OSError as error:
+                print(error)
+
         # FIXME: the --all should NOT be needed.
         # See: https://gitlab.gnome.org/GNOME/tracker-miners/-/issues/116
         output = self.run_cli(
@@ -51,6 +59,10 @@ class TestCli(fixtures.TrackerCommandLineTestCase):
         self.assertIn(target1.as_uri(), output)
         self.assertNotIn(target2.as_uri(), output)
 
+        folder_output = self.run_cli(
+            ['tracker3', 'search', '--folders', 'test-monitored'])
+        self.assertIn(self.indexed_dir, folder_output)
+        self.assertNotIn(folder_path.as_uri(), folder_output)
 
 if __name__ == '__main__':
     fixtures.tracker_test_main()
diff --git a/tests/functional-tests/fixtures.py b/tests/functional-tests/fixtures.py
index 56ebbbf6f..a118cd17c 100644
--- a/tests/functional-tests/fixtures.py
+++ b/tests/functional-tests/fixtures.py
@@ -156,6 +156,15 @@ class TrackerMinerTest(ut.TestCase):
 
         return self.tracker.await_insert(DOCUMENTS_GRAPH, '; '.join(expected), timeout=cfg.AWAIT_TIMEOUT)
 
+    def await_insert_dir(self, path):
+        if isinstance(path, pathlib.Path):
+            url = path.as_uri()
+        else:
+            url = self.uri(path)
+
+        expected = f'nie:isStoredAs <{url}>'
+        return self.tracker.await_insert(FILESYSTEM_GRAPH, expected, timeout=cfg.AWAIT_TIMEOUT)
+
     def await_document_uri_change(self, resource_id, from_path, to_path):
         """Wraps await_update() context manager."""
         from_url = self.uri(from_path)


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