Beispiel #1
0
 def test_expiry_range_batched(self):
     upper_bound_mock = mock.Mock(side_effect=[1, "final value"])
     sess_mock = mock.Mock()
     query_mock = sess_mock.query().filter().order_by().offset().limit()
     query_mock.one.side_effect = [["test"], sql.NotFound()]
     for i, x in enumerate(token_sql._expiry_range_batched(sess_mock, upper_bound_mock, batch_size=50)):
         if i == 0:
             # The first time the batch iterator returns, it should return
             # the first result that comes back from the database.
             self.assertEqual("test", x)
         elif i == 1:
             # The second time, the database range function should return
             # nothing, so the batch iterator returns the result of the
             # upper_bound function
             self.assertEqual("final value", x)
         else:
             self.fail("range batch function returned more than twice")
Beispiel #2
0
 def test_expiry_range_batched(self):
     upper_bound_mock = mock.Mock(side_effect=[1, "final value"])
     sess_mock = mock.Mock()
     query_mock = sess_mock.query().filter().order_by().offset().limit()
     query_mock.one.side_effect = [['test'], sql.NotFound()]
     for i, x in enumerate(token_sql._expiry_range_batched(sess_mock,
                                                           upper_bound_mock,
                                                           batch_size=50)):
         if i == 0:
             # The first time the batch iterator returns, it should return
             # the first result that comes back from the database.
             self.assertEqual('test', x)
         elif i == 1:
             # The second time, the database range function should return
             # nothing, so the batch iterator returns the result of the
             # upper_bound function
             self.assertEqual("final value", x)
         else:
             self.fail("range batch function returned more than twice")