diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-11 21:06:26 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-11 21:06:26 +0100 |
commit | 277c063e32e52106956b570e5d965d663969c79f (patch) | |
tree | 319948df294f6800bc4f1fd4964625cdfcc3d7df /tests/test_collection.py | |
parent | ad04af4812bbdebe47ce58333cc48332197e61b1 (diff) |
Load some data into xapian
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r-- | tests/test_collection.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py index 64dd293..d0a9864 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -1,3 +1,4 @@ +import logging import os.path import shutil import unittest @@ -11,8 +12,11 @@ class testCollectionLoading(unittest.TestCase): def test_empty(self): self.collection = lesana.Collection('tests/data/empty') - self.assertIsNone(self.collection.schema) + self.assertEqual(self.collection.schema, {}) self.assertIsNotNone(self.collection.cache) + self.assertIsNotNone(self.collection.stemmer) + + self.collection.update_cache() def test_simple(self): self.collection = lesana.Collection('tests/data/simple') @@ -20,3 +24,17 @@ class testCollectionLoading(unittest.TestCase): self.assertEqual(self.collection.schema['name'], "Simple lesana collection") self.assertEqual(len(self.collection.schema['fields']), 3) self.assertIsNotNone(self.collection.cache) + self.assertIsNotNone(self.collection.stemmer) + + self.collection.update_cache() + + def test_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') + self.assertEqual(len(cm.output), 1) + self.assertIn("Invalid language", cm.output[0]) + # The collection will default to english, but should still work. + self.assertIsNotNone(self.collection.schema) + self.assertIsNotNone(self.collection.cache) + self.assertIsNotNone(self.collection.stemmer) |