Exemplo n.º 1
0
 def test__connect_slave_ok_on_first_try(self):
     pool = pyredis.pool.SentinelPool(sentinels=[("host1", 12345)], name="mymaster", slave_ok=True)
     pool._get_master = Mock()
     client_mock = Mock()
     pool._get_slave = Mock()
     pool._get_slave.return_value = client_mock
     client = pool._connect()
     pool._get_slave.assert_called_with()
     self.assertEqual(client, client_mock)
Exemplo n.º 2
0
 def test__connect_slave_ok_on_second_try(self):
     pool = pyredis.pool.SentinelPool(sentinels=[("host1", 12345)], name="mymaster", slave_ok=True)
     pool._get_master = Mock()
     client_mock = Mock()
     pool._get_slave = Mock()
     pool._get_slave.side_effect = [None, client_mock]
     client = pool._connect()
     pool._get_slave.assert_has_calls([call(), call()])
     self.assertEqual(client, client_mock)
Exemplo n.º 3
0
 def test__connect_slave_ok_on_first_try(self):
     pool = pyredis.pool.SentinelPool(sentinels=[('host1', 12345)], name='mymaster', slave_ok=True)
     pool._get_master = Mock()
     client_mock = Mock()
     pool._get_slave = Mock()
     pool._get_slave.return_value = client_mock
     client = pool._connect()
     pool._get_slave.assert_called_with()
     self.assertEqual(client, client_mock)
Exemplo n.º 4
0
 def test__connect_master_ok_on_second_try(self):
     pool = pyredis.pool.SentinelPool(sentinels=[('host1', 12345)],
                                      name='mymaster')
     pool._get_master = Mock()
     client_mock = Mock()
     pool._get_master.side_effect = [None, client_mock]
     pool._get_slave = Mock()
     client = pool._connect()
     pool._get_master.assert_has_calls([call(), call()])
     self.assertEqual(client, client_mock)