Beispiel #1
0
    def setUp(self):
        self.mock_redis = mock.MagicMock(spec=redis.StrictRedis)

        self.uuid_patch = mock.patch(
            "uuid.uuid4",
            return_value=uuid.UUID("{12345678-1234-1234-1234-123456781234}"))
        self.uuid_patch.start()
        self.addCleanup(self.uuid_patch.stop)

        self.time_patch = mock.patch("time.time", return_value=12.34)
        self.mock_time = self.time_patch.start()
        self.addCleanup(self.time_patch.stop)

        self.log_info_patch = mock.patch("logging.info", autospec=True)
        self.log_info = self.log_info_patch.start()
        self.addCleanup(self.log_info_patch.stop)

        self.log_debug_patch = mock.patch("logging.debug", autospec=True)
        self.log_debug = self.log_debug_patch.start()
        self.addCleanup(self.log_debug_patch.stop)

        self.queue = RedisQueue("some.queue", self.mock_redis)
Beispiel #2
0
 def get_listener(self, queue_name):
     redis_queue = RedisQueue(queue_name, self._redis)
     return Listener(redis_queue, self.get_task)
Beispiel #3
0
    def get_processor(self, task):
        redis_queue = RedisQueue(task.queue, self._redis)

        return Processor(task, redis_queue)
Beispiel #4
0
 def get_queue(self, name):
     redis_queue = RedisQueue(name, self._redis)
     return Queue(name, redis_queue)