def test_pop_with_default_block_lpops(self): redis = MagicMock() key = MagicMock() redis_list = RedisList(redis, key) result = redis_list.pop() redis.lpop.assert_called_once_with(key, encoding='utf-8') self.assertEqual(result, redis.lpop.return_value)
def test_pop_with_block_and_default_timeout_blpops_with_zero_timeout(self): redis = MagicMock() key = MagicMock() redis_list = RedisList(redis, key) result = redis_list.pop(block=True) redis.blpop.assert_called_once_with(key, timeout=0, encoding='utf-8') self.assertEqual(result, redis.blpop.return_value)
def test_pop_with_no_block_lpops(self): redis = MagicMock() key = MagicMock() encoding = MagicMock() redis_list = RedisList(redis, key) result = redis_list.pop(block=False, encoding=encoding) redis.lpop.assert_called_once_with(key, encoding=encoding) self.assertEqual(result, redis.lpop.return_value)
def test_pop_with_reverse_and_default_block_rpops(self): redis = MagicMock() key = MagicMock() encoding = MagicMock() redis_list = RedisList(redis, key) result = redis_list.pop(reverse=True, encoding=encoding) redis.rpop.assert_called_once_with(key, encoding=encoding) self.assertEqual(result, redis.rpop.return_value)
def test_pop_with_block_blpops(self): redis = MagicMock() key = MagicMock() timeout = MagicMock() encoding = MagicMock() redis_list = RedisList(redis, key) result = redis_list.pop(block=True, timeout_seconds=timeout, encoding=encoding) redis.blpop.assert_called_once_with(key, timeout=timeout, encoding=encoding) self.assertEqual(result, redis.blpop.return_value)