From b4b6e6723a3b4fe107e607ce0ec5b81f72e72a5a Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Fri, 6 Jan 2017 20:42:43 +0100 Subject: Changed search interface to be closer to xapian expectations --- tests/test_collection.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests/test_collection.py') diff --git a/tests/test_collection.py b/tests/test_collection.py index d8190ca..a2c1a87 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -61,14 +61,31 @@ class testCollectionLoading(unittest.TestCase): self.collection.safe = False self.collection.update_cache() + def test_full_search(self): + self.collection = lesana.Collection('tests/data/simple') + self.collection.start_search('Item') + res = self.collection.get_all_search_results() + matches = list(res) + self.assertEqual(len(matches), 2) + for m in matches: + self.assertIsInstance(m, lesana.Entry) + def test_search(self): self.collection = lesana.Collection('tests/data/simple') - res = self.collection.search('Item') + self.collection.start_search('Item') + res = self.collection.get_search_results() matches = list(res) self.assertEqual(len(matches), 2) for m in matches: self.assertIsInstance(m, lesana.Entry) + def test_search_non_init(self): + self.collection = lesana.Collection('tests/data/simple') + matches = list(self.collection.get_search_results()) + self.assertEqual(matches, []) + matches = list(self.collection.get_all_search_results()) + self.assertEqual(matches, []) + def test_entry_from_uid(self): self.collection = lesana.Collection('tests/data/simple') entry = self.collection.entry_from_uid( @@ -197,3 +214,7 @@ class testCollectionCreation(unittest.TestCase): self.assertTrue(os.path.isfile(os.path.join(tmpdir, 'settings.yaml'))) self.assertFalse(os.path.isfile(os.path.join(tmpdir, '.gitignore'))) shutil.rmtree(tmpdir) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3