コード例 #1
0
    def test_dequeue_with_no_block_rpops(self):
        redis = MagicMock()
        key = MagicMock()
        encoding = MagicMock()
        redis_list = RedisList(redis, key)

        result = redis_list.dequeue(encoding=encoding)

        redis.rpop.assert_called_once_with(key, encoding=encoding)
        self.assertEqual(result, redis.rpop.return_value)
コード例 #2
0
    def test_dequeue_with_block_and_default_timeout_brpops_with_zero_timeout(
            self):
        redis = MagicMock()
        key = MagicMock()
        encoding = MagicMock()
        redis_list = RedisList(redis, key)

        result = redis_list.dequeue(block=True, encoding=encoding)

        redis.brpop.assert_called_once_with(key, timeout=0, encoding=encoding)
        self.assertEqual(result, redis.brpop.return_value)
コード例 #3
0
    def test_dequeue_with_block_brpops(self):
        redis = MagicMock()
        key = MagicMock()
        timeout = MagicMock()
        encoding = MagicMock()
        redis_list = RedisList(redis, key)

        result = redis_list.dequeue(block=True,
                                    timeout_seconds=timeout,
                                    encoding=encoding)

        redis.brpop.assert_called_once_with(key,
                                            timeout=timeout,
                                            encoding=encoding)
        self.assertEqual(result, redis.brpop.return_value)