[tracker-miners: 1/2] cli.py: tests for the tracker search




commit f5f8b47d26de7f149506bae714f05fbca92c1437
Author: nis130 <nishitlimbani130 gmail com>
Date:   Thu Dec 17 18:05:11 2020 +0530

    cli.py: tests for the tracker search
    
    created seprate function text_search_filename
    for adding tests related to file search

 tests/functional-tests/cli.py                       | 18 ++++++++++++++++++
 tests/functional-tests/test-cli-data/text/mango.txt |  3 +++
 2 files changed, 21 insertions(+)
---
diff --git a/tests/functional-tests/cli.py b/tests/functional-tests/cli.py
index 2153cfc17..96eb3e531 100644
--- a/tests/functional-tests/cli.py
+++ b/tests/functional-tests/cli.py
@@ -64,5 +64,23 @@ class TestCli(fixtures.TrackerCommandLineTestCase):
         self.assertIn(self.indexed_dir, folder_output)
         self.assertNotIn(folder_path.as_uri(), folder_output)
 
+
+    def test_search_filename(self):
+        datadir = pathlib.Path(__file__).parent.joinpath('test-cli-data')
+
+        file1 = datadir.joinpath('text/mango.txt')
+        target1 = pathlib.Path(os.path.join(self.indexed_dir, os.path.basename(file1)))
+        with self.await_document_inserted(target1):
+            shutil.copy(file1, self.indexed_dir)
+
+        target2 = pathlib.Path(os.path.join(self.indexed_dir, 'Document 2.txt'))
+
+        search_output = self.run_cli(
+            ['tracker3', 'search', 'mango'])
+        self.assertIn(target1.as_uri(), search_output)
+        self.assertNotIn(target2.as_uri(), search_output)
+
+
+
 if __name__ == '__main__':
     fixtures.tracker_test_main()
diff --git a/tests/functional-tests/test-cli-data/text/mango.txt 
b/tests/functional-tests/test-cli-data/text/mango.txt
new file mode 100644
index 000000000..f99490ce4
--- /dev/null
+++ b/tests/functional-tests/test-cli-data/text/mango.txt
@@ -0,0 +1,3 @@
+monkey
+
+lorem ipusm dolor sit amet
\ No newline at end of file


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