Example #1
0
 def chord_context(self, size=1):
     with patch('celery.backends.redis.maybe_signature') as ms:
         tasks = [self.create_task() for i in range(size)]
         request = Mock(name='request')
         request.id = 'id1'
         request.group = 'gid1'
         callback = ms.return_value = Signature('add')
         callback.id = 'id1'
         callback['chord_size'] = size
         callback.delay = Mock(name='callback.delay')
         yield tasks, request, callback
Example #2
0
 def chord_context(self, size=1):
     with patch("celery.backends.redis.maybe_signature") as ms:
         tasks = [self.create_task() for i in range(size)]
         request = Mock(name="request")
         request.id = "id1"
         request.group = "gid1"
         callback = ms.return_value = Signature("add")
         callback.id = "id1"
         callback["chord_size"] = size
         callback.delay = Mock(name="callback.delay")
         yield tasks, request, callback
Example #3
0
    def MockMessage(self, id=None, receipt_handle=None, body=None):
        m = Mock(name='message')
        m.id = id or uuid()
        m.receipt_handle = receipt_handle or uuid()
        m._body = body

        def _get_body():
            return m._body
        m.get_body.side_effect = _get_body

        def _set_body(value):
            m._body = value
        m.set_body.side_effect = _set_body

        return m
Example #4
0
 def MockMessage(self, id, md5):
     m = Mock(name='Message-{0}'.format(id))
     m.id = id
     m.md5 = md5
     return m