diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/data/wrong/settings.yaml | 3 | ||||
| -rw-r--r-- | tests/test_collection.py | 24 | 
2 files changed, 23 insertions, 4 deletions
| diff --git a/tests/data/wrong/settings.yaml b/tests/data/wrong/settings.yaml index 83a542b..bf79572 100644 --- a/tests/data/wrong/settings.yaml +++ b/tests/data/wrong/settings.yaml @@ -23,3 +23,6 @@ fields:        type: list        list: string        index: field +    - name: cloud +      type: cloud +      help: 'There is no cloud type' diff --git a/tests/test_collection.py b/tests/test_collection.py index 832f421..f7ddf6d 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -305,6 +305,22 @@ class testComplexCollection(unittest.TestCase):          self.assertIn('with_default', entry.yaml_data)          self.assertIn('amount: 0', entry.yaml_data) +    def test_load_field_loaders(self): +        # Check that all fields have been loaded, with the right types +        to_test = ( +            ('name', lesana.types.LesanaString), +            ('description', lesana.types.LesanaText), +            ('position', lesana.types.LesanaString), +            ('something', lesana.types.LesanaYAML), +            ('tags', lesana.types.LesanaList), +            ('keywords', lesana.types.LesanaList), +            ('exists', lesana.types.LesanaBoolean), +            ('with_default', lesana.types.LesanaString), +            ('amount', lesana.types.LesanaInt), +        ) +        for f in to_test: +            self.assertIsInstance(self.collection.fields[f[0]], f[1]) +  class testCollectionWithErrors(unittest.TestCase):      def setUp(self): @@ -320,8 +336,8 @@ class testCollectionWithErrors(unittest.TestCase):          # check that the log contains a warning.          with self.assertLogs(level=logging.WARNING) as cm:              self.collection = lesana.Collection(self.tmpdir) -        self.assertEqual(len(cm.output), 1) -        self.assertIn("Invalid language", cm.output[0]) +        self.assertEqual(len(cm.output), 2) +        self.assertIn("Invalid language", cm.output[1])          # The collection will default to english, but should still work.          self.collection.update_cache()          self.assertIsNotNone(self.collection.settings) @@ -334,7 +350,7 @@ class testCollectionWithErrors(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']), 7) +        self.assertEqual(len(self.collection.settings['fields']), 8)          self.assertEqual(len(self.collection.indexed_fields), 3)      def test_init(self): @@ -343,7 +359,7 @@ class testCollectionWithErrors(unittest.TestCase):              self.collection.settings['name'],              "Lesana collection with certain errors",          ) -        self.assertEqual(len(self.collection.settings['fields']), 7) +        self.assertEqual(len(self.collection.settings['fields']), 8)          self.assertIsNotNone(self.collection.stemmer)          self.assertEqual(len(self.collection.indexed_fields), 3) | 
