Example #1
0
 def find_query(self, wanted, orderings, default):
     """
     Given the list of order statements and a query that is currently
     found in the request's querystring returns the next in line,
     or falls back to the given default.
     """
     for current, next in cycle_pairs(orderings):
         if current == wanted:
             return next
     return default
Example #2
0
 def find_query(self, wanted, orderings, default):
     """
     Given the list of order statements and a query that is currently
     found in the request's querystring returns the next in line,
     or falls back to the given default.
     """
     for current, next in cycle_pairs(orderings):
         if current == wanted:
             return next
     return default
Example #3
0
 def test_cycle_pairs(self):
     self.assertEqual(list(cycle_pairs([1, 2, 3])), [(1, 2), (2, 3),
                                                     (3, 1)])
Example #4
0
 def test_cycle_pairs(self):
     self.assertEqual(list(cycle_pairs([1, 2, 3])), [(1, 2), (2, 3), (3, 1)])