summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_collection.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index f3e06da..8d4cf88 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -332,6 +332,27 @@ class testComplexCollection(unittest.TestCase):
with open(fname, 'r') as fp:
self.assertEqual(e.yaml_data, fp.read())
+ def test_sorted_search(self):
+ # search in ascending order
+ self.collection.start_search('Amount', sort_by=['amount'])
+ res = self.collection.get_search_results()
+ matches = list(res)
+ self.assertEqual(len(matches), 4)
+ self.assertEqual(matches[0].data['amount'], 2)
+ self.assertEqual(matches[1].data['amount'], 10)
+ self.assertEqual(matches[2].data['amount'], 15)
+ self.assertEqual(matches[3].data['amount'], 20)
+
+ # and in descending order
+ self.collection.start_search('Amount', sort_by=['-amount'])
+ res = self.collection.get_search_results()
+ matches = list(res)
+ self.assertEqual(len(matches), 4)
+ self.assertEqual(matches[0].data['amount'], 20)
+ self.assertEqual(matches[1].data['amount'], 15)
+ self.assertEqual(matches[2].data['amount'], 10)
+ self.assertEqual(matches[3].data['amount'], 2)
+
class testCollectionWithErrors(unittest.TestCase):
def setUp(self):