async def test_conn_reuses(self, redis, redis_connection, mocker): mocker.spy(self, "dummy") d = conn(self.dummy) await d(redis, "a", _conn=redis_connection) self.dummy.assert_called_with(redis, "a", _conn=redis_connection) await d(redis, "a", _conn=redis_connection) self.dummy.assert_called_with(redis, "a", _conn=redis_connection)
async def test_conn_no_pool(self, redis, mocker): mocker.spy(self, "dummy") cache, pool = redis cache._pool = pool d = conn(self.dummy) await d(cache, "a", _conn=None) d.assert_called_with(cache, "a", _conn=pool.conn) pool.conn = "another_connection" await d(cache, "a", _conn=None) d.assert_called_with(cache, "a", _conn="another_connection")