diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-06 20:42:43 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-06 20:42:43 +0100 |
commit | b4b6e6723a3b4fe107e607ce0ec5b81f72e72a5a (patch) | |
tree | e0c67d2b94dc092152d7e89073bd0bd5b776d8a5 /tests | |
parent | 1210c3fbd35c0a94725fded04a92f3e06ec27f0b (diff) |
Changed search interface to be closer to xapian expectations
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_collection.py | 23 |
1 files changed, 22 insertions, 1 deletions
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() |