aboutsummaryrefslogtreecommitdiff
path: root/tests/test_collection.py
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-11-21 16:56:21 +0100
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2017-11-21 16:56:21 +0100
commitbb14bc77bd21284136ed7cc092b93c1a8d6026c1 (patch)
tree4fb57b42da2e5cc24367ad9dbca682ab8be5a80b /tests/test_collection.py
parent043e99bf5416e0899c02490fa600be4cfd049da1 (diff)
parent851914e5da250e6a38e83bccf182ab8af1db0d32 (diff)
Merge branch 'master' into tellico
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r--tests/test_collection.py48
1 files changed, 45 insertions, 3 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index 869828a..84f0a7a 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -54,7 +54,7 @@ class testCollection(unittest.TestCase):
self.assertIsNotNone(self.collection.settings)
self.assertIsNotNone(self.collection.stemmer)
# Fields with no "index" entry are not indexed
- self.assertEqual(len(self.collection.settings['fields']), 3)
+ self.assertEqual(len(self.collection.settings['fields']), 4)
self.assertEqual(len(self.collection.indexed_fields), 1)
def test_load_safe(self):
@@ -80,6 +80,15 @@ class testCollection(unittest.TestCase):
for m in matches:
self.assertIsInstance(m, lesana.Entry)
+ def test_search_wildcard(self):
+ self.collection = lesana.Collection('tests/data/simple')
+ self.collection.start_search('Ite*')
+ 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())
@@ -232,13 +241,46 @@ class testComplexCollection(unittest.TestCase):
self.collection.settings['name'],
"Fully featured lesana collection"
)
- self.assertEqual(len(self.collection.settings['fields']), 4)
+ self.assertEqual(len(self.collection.settings['fields']), 5)
self.assertIsNotNone(self.collection.stemmer)
- self.assertEqual(len(self.collection.indexed_fields), 2)
+ self.assertEqual(len(self.collection.indexed_fields), 4)
def test_index(self):
self.collection.update_cache()
+ def test_indexing_list(self):
+ self.collection.update_cache(['73097121f1874a6ea2f927db7dc4f11e.yaml'])
+ self.collection.start_search('tags:this')
+ res = self.collection.get_search_results()
+ matches = list(res)
+ self.assertEqual(len(matches), 1)
+ for m in matches:
+ self.assertIsInstance(m, lesana.Entry)
+
+
+class testCollectionWithErrors(unittest.TestCase):
+ @classmethod
+ def setUpClass(self):
+ self.collection = lesana.Collection('tests/data/wrong')
+
+ @classmethod
+ def tearDownClass(self):
+ shutil.rmtree(os.path.join(self.collection.basedir, '.lesana'))
+
+ def test_init(self):
+ self.assertIsNotNone(self.collection.settings)
+ self.assertEqual(
+ self.collection.settings['name'],
+ "Lesana collection with certain errors"
+ )
+ self.assertEqual(len(self.collection.settings['fields']), 4)
+ self.assertIsNotNone(self.collection.stemmer)
+ self.assertEqual(len(self.collection.indexed_fields), 1)
+
+ def test_index(self):
+ loaded = self.collection.update_cache()
+ self.assertEqual(loaded, 0)
+
class testCollectionCreation(unittest.TestCase):
def test_init(self):