diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-12-23 16:08:00 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-12-23 16:08:00 +0100 |
commit | f37ef6193eaf8c02272c656314e615e6d3ae0a02 (patch) | |
tree | cac15085e5f780479815057bc996c7f382e5ce6d /tests | |
parent | 9e9492fad4d58c6a19b091f3b85b3250700bfe86 (diff) |
Limit a field to one among a list of values
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/wrong/items/139770330d344a2f9d73945fab3bf47b.yaml | 16 | ||||
-rw-r--r-- | tests/data/wrong/items/7496e7b7763b44d994ed07c134e66bdc.yaml | 14 | ||||
-rw-r--r-- | tests/data/wrong/settings.yaml | 6 | ||||
-rw-r--r-- | tests/test_collection.py | 4 |
4 files changed, 38 insertions, 2 deletions
diff --git a/tests/data/wrong/items/139770330d344a2f9d73945fab3bf47b.yaml b/tests/data/wrong/items/139770330d344a2f9d73945fab3bf47b.yaml new file mode 100644 index 0000000..84d2648 --- /dev/null +++ b/tests/data/wrong/items/139770330d344a2f9d73945fab3bf47b.yaml @@ -0,0 +1,16 @@ +name: 'invalid owner' +description: | + This entry has an owner that is not on the list of allowed owners. +position: '' +# # number (integer): Enter an integer here +number: 0 +# # float (float): Enter a floating point number here +float: 0.0 +# # price (decimal): prices are never float! +price: '0' +things: [] +# # cloud (cloud): There is no cloud type +cloud: +category: '' +owners: + - them diff --git a/tests/data/wrong/items/7496e7b7763b44d994ed07c134e66bdc.yaml b/tests/data/wrong/items/7496e7b7763b44d994ed07c134e66bdc.yaml new file mode 100644 index 0000000..e0ca190 --- /dev/null +++ b/tests/data/wrong/items/7496e7b7763b44d994ed07c134e66bdc.yaml @@ -0,0 +1,14 @@ +name: 'Invalid category value' +description: | + An entry where the category isn't in the list of valid values +position: '' +# # number (integer): Enter an integer here +number: 0 +# # float (float): Enter a floating point number here +float: 0.0 +# # price (decimal): prices are never float! +price: '0' +things: [] +# # cloud (cloud): There is no cloud type +cloud: +category: 'zeroeth' diff --git a/tests/data/wrong/settings.yaml b/tests/data/wrong/settings.yaml index 6b3a3bb..73ce6d9 100644 --- a/tests/data/wrong/settings.yaml +++ b/tests/data/wrong/settings.yaml @@ -32,3 +32,9 @@ fields: - first - second - third + - name: owners + type: list + list: string + values: + - me + - myself diff --git a/tests/test_collection.py b/tests/test_collection.py index 00389cd..659671d 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -574,7 +574,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']), 9) + self.assertEqual(len(self.collection.settings['fields']), 10) self.assertEqual(len(self.collection.indexed_fields), 3) def test_init(self): @@ -583,7 +583,7 @@ class testCollectionWithErrors(unittest.TestCase): self.collection.settings['name'], "Lesana collection with certain errors", ) - self.assertEqual(len(self.collection.settings['fields']), 9) + self.assertEqual(len(self.collection.settings['fields']), 10) self.assertIsNotNone(self.collection.stemmer) self.assertEqual(len(self.collection.indexed_fields), 3) |