diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-02-03 11:24:46 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2021-02-03 11:24:46 +0100 |
commit | 23de3297bbd74980a2f6da326acc5da63ddef2fe (patch) | |
tree | fc670e596e96a2147ee0f27a838072ba98645e25 /tests/test_collection.py | |
parent | de1c03d81615e6fd50540008fe6ca46feb012c30 (diff) |
Add a default_sort option to collections
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r-- | tests/test_collection.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py index 6a6e5e3..4c95c2b 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -289,9 +289,9 @@ class testComplexCollection(unittest.TestCase): self.collection.settings['name'], "Fully featured lesana collection", ) - 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), 7) + self.assertEqual(len(self.collection.indexed_fields), 8) def test_index(self): indexed = self.collection.update_cache() @@ -379,6 +379,18 @@ class testComplexCollection(unittest.TestCase): self.assertEqual(matches[2].data['amount'], 10) self.assertEqual(matches[3].data['amount'], 2) + def test_default_sorted_search(self): + # search in ascending order + self.collection.start_search('Amount') + res = self.collection.get_search_results() + matches = list(res) + self.assertEqual(len(matches), 4) + print([m.data['order'] for m in matches]) + self.assertEqual(matches[0].data['order'], None) + self.assertEqual(matches[1].data['order'], 'alpha') + self.assertEqual(matches[2].data['order'], 'charlie') + self.assertEqual(matches[3].data['order'], 'zucchini') + class testCollectionWithErrors(unittest.TestCase): def setUp(self): |