diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-06 21:08:07 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-06 21:08:07 +0100 |
commit | bb451cf5ab9f3db35c91b79c0f2bbdc27a29a0e1 (patch) | |
tree | e51a83a2c67a7e28e9ab8514091b702534d7e5fa /tests | |
parent | 0eb031fc93630731f2344deda8123e36c0375235 (diff) |
Improved test coverage
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml | 5 | ||||
-rw-r--r-- | tests/test_collection.py | 24 |
2 files changed, 23 insertions, 6 deletions
diff --git a/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml b/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml new file mode 100644 index 0000000..7a0f5d7 --- /dev/null +++ b/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml @@ -0,0 +1,5 @@ +name: 'Mostly empty entry' +description: +position: +quantity: +other: diff --git a/tests/test_collection.py b/tests/test_collection.py index beab6e0..3959399 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -9,7 +9,7 @@ import ruamel.yaml import lesana -class testCollectionLoading(unittest.TestCase): +class testCollection(unittest.TestCase): def tearDown(self): shutil.rmtree(os.path.join(self.collection.basedir, '.lesana')) @@ -20,7 +20,7 @@ class testCollectionLoading(unittest.TestCase): self.collection.update_cache() self.assertIsNotNone(self.collection.stemmer) - def test_simple(self): + def test_load_simple(self): self.collection = lesana.Collection('tests/data/simple') self.assertIsNotNone(self.collection.settings) self.assertEqual( @@ -33,7 +33,7 @@ class testCollectionLoading(unittest.TestCase): self.collection.update_cache() self.assertIsNotNone(self.collection.stemmer) - def test_wrong_language(self): + def test_load_wrong_language(self): # This loads a collection with an invalid value in lang with self.assertLogs(level=logging.WARNING) as cm: self.collection = lesana.Collection('tests/data/wrong') @@ -44,7 +44,7 @@ class testCollectionLoading(unittest.TestCase): self.assertIsNotNone(self.collection.settings) self.assertIsNotNone(self.collection.stemmer) - def test_no_index_for_one_entry(self): + def test_load_no_index_for_one_entry(self): # This loads a collection where some of the entries have no # "index" field with self.assertLogs(level=logging.WARNING): @@ -56,9 +56,9 @@ class testCollectionLoading(unittest.TestCase): self.assertEqual(len(self.collection.settings['fields']), 3) self.assertEqual(len(self.collection.indexed_fields), 1) - def test_unsafe(self): + def test_load_safe(self): self.collection = lesana.Collection('tests/data/simple') - self.collection.safe = False + self.collection.safe = True self.collection.update_cache() def test_full_search(self): @@ -92,6 +92,18 @@ class testCollectionLoading(unittest.TestCase): '11189ee47ddf4796b718a483b379f976' ) self.assertEqual(entry.uid, '11189ee47ddf4796b718a483b379f976') + self.collection.safe = True + entry = self.collection.entry_from_uid( + '11189ee47ddf4796b718a483b379f976' + ) + self.assertEqual(entry.uid, '11189ee47ddf4796b718a483b379f976') + + def test_index_missing_file(self): + self.collection = lesana.Collection('tests/data/simple') + with self.assertLogs(level=logging.WARNING) as cm: + self.collection.update_cache(['non_existing_file']) + self.assertEqual(len(cm.output), 1) + self.assertIn("non_existing_file", cm.output[0]) class testEntries(unittest.TestCase): |