diff options
Diffstat (limited to 'tests/test_collection.py')
| -rw-r--r-- | tests/test_collection.py | 24 | 
1 files changed, 18 insertions, 6 deletions
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):  | 
