Example #1
0
 def setUp(self):
     """ setup any state tied to the execution of the given method in a
     class.  setup_method is invoked for every test method of a class.
     """
     self.cache = RedisStorage(RedisMock(), prefix='pre::', encoder=json)
     self.recommendations = RedisStorage(RedisMock(), 'recommendations::')
     self.queues = RedisQueue(RedisMock(), encoder=json)
     self.obelix = Obelix(self.cache, self.recommendations, self.queues)
Example #2
0
    def test_lpush_and_rpop(self):
        queue = RedisQueue(RedisMock())
        #  Fill queue One and Two
        for i in range(0, 12):
            queue.lpush("One", i)
            queue.lpush("Two", i + 30)

        # Check
        for i in range(0, 12):
            assert queue.rpop("One") == i
            assert queue.rpop("Two") == i + 30
Example #3
0
    def test_redis_queue_rpush_lpop_with_encoder_prefix(self):
        queue = RedisQueue(RedisMock(), prefix='pre::', encoder=json)

        data1 = {"test": [1, 2, 3]}
        data2 = [1, 2, 3]
        queue.rpush("q1", 111111)
        queue.rpush("q2", 222222)
        queue.rpush("q1", data1)
        queue.rpush("q2", data2)
        queue.rpush("q1", 555555)
        queue.rpush("q2", 666666)

        assert queue.lpop("q1") == 111111
        assert queue.lpop("q1") == data1
        assert queue.lpop("q1") == 555555

        assert queue.lpop("q2") == 222222
        assert queue.lpop("q2") == data2
        assert queue.lpop("q2") == 666666