diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-27 09:28:32 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2016-12-27 09:29:11 +0100 |
commit | ba68390361631becba819bd076259a43d21c32d5 (patch) | |
tree | 00f4663861f0b132e9dfb3ceab21c20429d37b3d /tests | |
parent | 0038a648a74236e33144cb8c3bce42a0873ec44f (diff) |
Don't die when a settings entry has no 'index' field.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/wrong/settings.yaml | 1 | ||||
-rw-r--r-- | tests/test_collection.py | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/tests/data/wrong/settings.yaml b/tests/data/wrong/settings.yaml index 56031e4..9871421 100644 --- a/tests/data/wrong/settings.yaml +++ b/tests/data/wrong/settings.yaml @@ -6,7 +6,6 @@ fields: index: free - name: description type: text - index: free - name: position type: string index: facet diff --git a/tests/test_collection.py b/tests/test_collection.py index 9522ab8..7d2dc72 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -43,6 +43,18 @@ class testCollectionLoading(unittest.TestCase): self.assertIsNotNone(self.collection.settings) self.assertIsNotNone(self.collection.stemmer) + def test_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) as cm: + self.collection = lesana.Collection('tests/data/wrong') + self.collection.update_cache() + 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.indexed_fields), 1) + def test_unsafe(self): self.collection = lesana.Collection('tests/data/simple') self.collection.safe = False |