def test_resurrect_failed_all(self, asyncio): now = int(time.time()) c = HttpClient([('localhost', 1000), ('localhost', 1000)], resolve=False) c._hosts = [] c._failed.append((('localhost', 1000), now - 10)) c._failed.append((('localhost', 1001), now - 10)) c._resurrect_failed() self.assertEqual(c._hosts, [('localhost', 1000), ('localhost', 1001)]) self.assertFalse(asyncio.get_event_loop.return_value.call_later.called)
def test_resurrect_failed(self): now = int(time.time()) loop = unittest.mock.Mock() c = HttpClient([('localhost', 1000), ('localhost', 1000)], loop=loop) c._hosts = [] c._failed.append((('localhost', 1000), now - 10)) c._failed.append((('localhost', 1001), now - 10)) c._failed.append((('localhost', 1002), now + 10)) c._resurrect_failed() self.assertEqual(c._hosts, [('localhost', 1000), ('localhost', 1001)]) self.assertTrue(loop.call_later.called)
def test_resurrect_failed_all(self, asyncio): now = int(time.time()) c = HttpClient( [('localhost', 1000), ('localhost', 1000)], resolve=False) c._hosts = [] c._failed.append((('localhost', 1000), now - 10)) c._failed.append((('localhost', 1001), now - 10)) c._resurrect_failed() self.assertEqual( c._hosts, [('localhost', 1000), ('localhost', 1001)]) self.assertFalse( asyncio.get_event_loop.return_value.call_later.called)
def test_resurrect_failed(self): now = int(time.time()) loop = unittest.mock.Mock() c = HttpClient( [('localhost', 1000), ('localhost', 1000)], loop=loop) c._hosts = [] c._failed.append((('localhost', 1000), now - 10)) c._failed.append((('localhost', 1001), now - 10)) c._failed.append((('localhost', 1002), now + 10)) c._resurrect_failed() self.assertEqual( c._hosts, [('localhost', 1000), ('localhost', 1001)]) self.assertTrue(loop.call_later.called)