Example #1
0
 def testMul2(self):
     bi = simpleBackoffIterator(now=False,
                                initDelay=1.0,
                                incFunc=partial(mul, 2.0),
                                maxDelay=10.0,
                                maxResults=10)
     self.assertEqual(1.0, bi.next())
     self.assertEqual(2.0, bi.next())
     self.assertEqual(4.0, bi.next())
Example #2
0
 def testAdd3(self):
     bi = simpleBackoffIterator(now=False,
                                initDelay=2.0,
                                incFunc=partial(add, 3.0),
                                maxDelay=10.0,
                                maxResults=10)
     self.assertEqual(2.0, bi.next())
     self.assertEqual(5.0, bi.next())
     self.assertEqual(8.0, bi.next())
Example #3
0
 def testConstant(self):
     n = 10
     constant = 5.0
     initDelay = 3.0
     bi = simpleBackoffIterator(now=False,
                                initDelay=initDelay,
                                incFunc=lambda _: constant,
                                maxDelay=10.0,
                                maxResults=n + 1)
     self.assertEqual(initDelay, bi.next())
     for _ in range(n):
         self.assertEqual(constant, bi.next())
Example #4
0
 def testMaxResults(self):
     maxResults = 12
     bi = simpleBackoffIterator(now=False, maxResults=maxResults)
     for _ in range(maxResults):
         bi.next()
     self.assertRaises(StopIteration, bi.next)
Example #5
0
 def testDefaultSettingsNoNegativeDelays(self):
     bi = simpleBackoffIterator()
     for delay in bi:
         self.assertTrue(delay >= 0.0)
Example #6
0
 def testDefaultSettingsEventuallyHalt(self):
     bi = simpleBackoffIterator()
     for delay in bi:
         pass
Example #7
0
 def testInitDelay(self):
     initDelay = 7
     bi = simpleBackoffIterator(now=False, initDelay=initDelay,
                                maxDelay=initDelay + 1)
     delay = bi.next()
     self.assertEqual(initDelay, delay)
Example #8
0
 def testNotNow(self):
     bi = simpleBackoffIterator(now=False, initDelay=3.0)
     delay = bi.next()
     self.assertNotEqual(0.0, delay)
Example #9
0
 def testNow(self):
     bi = simpleBackoffIterator(now=True, initDelay=9)
     delay = bi.next()
     self.assertEqual(0.0, delay)