diff options
Diffstat (limited to 'tests/test_connection_pool.py')
-rw-r--r-- | tests/test_connection_pool.py | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/tests/test_connection_pool.py b/tests/test_connection_pool.py index 080e3df..2f8ffbf 100644 --- a/tests/test_connection_pool.py +++ b/tests/test_connection_pool.py @@ -43,21 +43,25 @@ class TestConnectionPool(object): assert isinstance(connection, DummyConnection) assert connection.kwargs == connection_kwargs - def test_multiple_connections(self): - pool = self.get_pool() + def test_multiple_connections(self, master_host): + connection_kwargs = {'host': master_host} + pool = self.get_pool(connection_kwargs=connection_kwargs) c1 = pool.get_connection('_') c2 = pool.get_connection('_') assert c1 != c2 - def test_max_connections(self): - pool = self.get_pool(max_connections=2) + def test_max_connections(self, master_host): + connection_kwargs = {'host': master_host} + pool = self.get_pool(max_connections=2, + connection_kwargs=connection_kwargs) pool.get_connection('_') pool.get_connection('_') with pytest.raises(redis.ConnectionError): pool.get_connection('_') - def test_reuse_previously_released_connection(self): - pool = self.get_pool() + def test_reuse_previously_released_connection(self, master_host): + connection_kwargs = {'host': master_host} + pool = self.get_pool(connection_kwargs=connection_kwargs) c1 = pool.get_connection('_') pool.release(c1) c2 = pool.get_connection('_') @@ -98,22 +102,25 @@ class TestBlockingConnectionPool(object): **connection_kwargs) return pool - def test_connection_creation(self): - connection_kwargs = {'foo': 'bar', 'biz': 'baz'} + def test_connection_creation(self, master_host): + connection_kwargs = {'foo': 'bar', 'biz': 'baz', 'host': master_host} pool = self.get_pool(connection_kwargs=connection_kwargs) connection = pool.get_connection('_') assert isinstance(connection, DummyConnection) assert connection.kwargs == connection_kwargs - def test_multiple_connections(self): - pool = self.get_pool() + def test_multiple_connections(self, master_host): + connection_kwargs = {'host': master_host} + pool = self.get_pool(connection_kwargs=connection_kwargs) c1 = pool.get_connection('_') c2 = pool.get_connection('_') assert c1 != c2 - def test_connection_pool_blocks_until_timeout(self): + def test_connection_pool_blocks_until_timeout(self, master_host): "When out of connections, block for timeout seconds, then raise" - pool = self.get_pool(max_connections=1, timeout=0.1) + connection_kwargs = {'host': master_host} + pool = self.get_pool(max_connections=1, timeout=0.1, + connection_kwargs=connection_kwargs) pool.get_connection('_') start = time.time() @@ -122,12 +129,14 @@ class TestBlockingConnectionPool(object): # we should have waited at least 0.1 seconds assert time.time() - start >= 0.1 - def connection_pool_blocks_until_another_connection_released(self): + def test_connection_pool_blocks_until_another_connection_released(self, master_host): """ When out of connections, block until another connection is released to the pool """ - pool = self.get_pool(max_connections=1, timeout=2) + connection_kwargs = {'host': master_host} + pool = self.get_pool(max_connections=1, timeout=2, + connection_kwargs=connection_kwargs) c1 = pool.get_connection('_') def target(): @@ -139,8 +148,9 @@ class TestBlockingConnectionPool(object): pool.get_connection('_') assert time.time() - start >= 0.1 - def test_reuse_previously_released_connection(self): - pool = self.get_pool() + def test_reuse_previously_released_connection(self, master_host): + connection_kwargs = {'host': master_host} + pool = self.get_pool(connection_kwargs=connection_kwargs) c1 = pool.get_connection('_') pool.release(c1) c2 = pool.get_connection('_') |