def test__sentinel_get(self): sentinels = [('host1', 12345), ('host2', 12345), ('host3', 12345)] client = pyredis.client.SentinelClient(sentinels=sentinels) client._sentinel_connect = Mock() client._conn = True client._sentinel_get() self.assertEqual(client.sentinels, deque(sentinels)) client._sentinel_connect.assert_called_with(('host1', 12345))
def test__sentinel_get(self): sentinels = [('host1', 12345), ('host2', 12345), ('host3', 12345)] client = pyredis.client.SentinelClient(sentinels=sentinels) client._sentinel_connect = Mock() client._conn = True client._sentinel_get() self.assertEqual(client.sentinels, deque(sentinels)) client._sentinel_connect.assert_called_with(('host1', 12345))
def test__sentinel_get_one_connect_err(self): sentinels = [('host1', 12345), ('host2', 12345), ('host3', 12345)] client = pyredis.client.SentinelClient(sentinels=sentinels) client._sentinel_connect = Mock() client._sentinel_connect.side_effect = (None, True) client._sentinel_get() roteted_sentinel = deque(sentinels) roteted_sentinel.rotate(-1) self.assertEqual(client.sentinels, roteted_sentinel) client._sentinel_connect.assert_has_calls( [call(('host1', 12345)), call(('host2', 12345))])
def test__sentinel_get_one_connect_err(self): sentinels = [('host1', 12345), ('host2', 12345), ('host3', 12345)] client = pyredis.client.SentinelClient(sentinels=sentinels) client._sentinel_connect = Mock() client._sentinel_connect.side_effect = (None, True) client._sentinel_get() roteted_sentinel = deque(sentinels) roteted_sentinel.rotate(-1) self.assertEqual(client.sentinels, roteted_sentinel) client._sentinel_connect.assert_has_calls([ call(('host1', 12345)), call(('host2', 12345)) ])