def test_simple(self): simple_gen._messages = [] self.assertEqual(simple_gen._messages, []) waiter = Waiter(simple_gen, interval=1) waiter.join() self.assertEqual(simple_gen._messages, [ 'Nope.', 'Yup.', ])
def test_exceeded_retries(self): client = Failed() waiter = Waiter(client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 1}, retries=1, interval=1) with self.assertRaises(RetriesExceededError) as cm: final = waiter.join() self.assertTrue('exceeded the number of retries' in str(cm.exception))
def test_exceeded_timeout(self): client = Complex() waiter = Waiter(client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 0.3}, retries=1, interval=1) with self.assertRaises(TimeoutExceededError) as cm: final = waiter.join(timeout=0.1) self.assertTrue('exceeded the timeout' in str(cm.exception))
def test_exceeded_retries(self): client = Failed() waiter = Waiter( client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 1}, retries=1, interval=1 ) with self.assertRaises(RetriesExceededError) as cm: final = waiter.join() self.assertTrue('exceeded the number of retries' in str(cm.exception))
def test_exceeded_timeout(self): client = Complex() waiter = Waiter( client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 0.3}, retries=1, interval=1 ) with self.assertRaises(TimeoutExceededError) as cm: final = waiter.join(timeout=0.1) self.assertTrue('exceeded the timeout' in str(cm.exception))
def test_complex(self): client = Complex() waiter = Waiter(client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 5}, retries=1, interval=0.5) waiter.messages = [] final = waiter.join(before_attempt=before_running, before_wait=before_sleeping) self.assertEqual(waiter.messages, [ "About to attempt 'request'...", "Whelp, that didn't work. Sleeping for 0.5...", "About to attempt 'request'..." ]) self.assertEqual( final, 'Got a 200 from http://aws.amazon.com/ in less than 5 seconds.')
def test_complex(self): client = Complex() waiter = Waiter( client.request, args=['http://aws.amazon.com/'], kwargs={'timeout': 5}, retries=1, interval=0.5 ) waiter.messages = [] final = waiter.join( before_attempt=before_running, before_wait=before_sleeping ) self.assertEqual(waiter.messages, [ "About to attempt 'request'...", "Whelp, that didn't work. Sleeping for 0.5...", "About to attempt 'request'..." ]) self.assertEqual( final, 'Got a 200 from http://aws.amazon.com/ in less than 5 seconds.' )