Exemplo n.º 1
0
    def test_on_chord_part_return(self, restore):
        tb = CacheBackend(backend='memory://', app=self.app)

        deps = Mock()
        deps.__len__ = Mock()
        deps.__len__.return_value = 2
        restore.return_value = deps
        task = Mock()
        task.name = 'foobarbaz'
        self.app.tasks['foobarbaz'] = task
        task.request.chord = signature(task)

        result = self.app.GroupResult(
            uuid(),
            [self.app.AsyncResult(uuid()) for _ in range(3)],
        )
        task.request.group = result.id
        tb.apply_chord(result, None)

        deps.join_native.assert_not_called()
        tb.on_chord_part_return(task.request, 'SUCCESS', 10)
        deps.join_native.assert_not_called()

        tb.on_chord_part_return(task.request, 'SUCCESS', 10)
        deps.join_native.assert_called_with(propagate=True, timeout=3.0)
        deps.delete.assert_called_with()
Exemplo n.º 2
0
    def test_on_chord_part_return(self, restore):
        tb = CacheBackend(backend='memory://', app=self.app)

        deps = Mock()
        deps.__len__ = Mock()
        deps.__len__.return_value = 2
        restore.return_value = deps
        task = Mock()
        task.name = 'foobarbaz'
        self.app.tasks['foobarbaz'] = task
        task.request.chord = signature(task)

        result = self.app.GroupResult(
            uuid(),
            [self.app.AsyncResult(uuid()) for _ in range(3)],
        )
        task.request.group = result.id
        tb.apply_chord(result, None)

        deps.join_native.assert_not_called()
        tb.on_chord_part_return(task.request, 'SUCCESS', 10)
        deps.join_native.assert_not_called()

        tb.on_chord_part_return(task.request, 'SUCCESS', 10)
        deps.join_native.assert_called_with(propagate=True, timeout=3.0)
        deps.delete.assert_called_with()
Exemplo n.º 3
0
 def test_apply_chord(self):
     tb = CacheBackend(backend='memory://', app=self.app)
     result = self.app.GroupResult(
         uuid(),
         [self.app.AsyncResult(uuid()) for _ in range(3)],
     )
     tb.apply_chord(result, None)
     assert self.app.GroupResult.restore(result.id, backend=tb) == result
Exemplo n.º 4
0
 def test_apply_chord(self):
     tb = CacheBackend(backend='memory://', app=self.app)
     result = self.app.GroupResult(
         uuid(),
         [self.app.AsyncResult(uuid()) for _ in range(3)],
     )
     tb.apply_chord(result, None)
     assert self.app.GroupResult.restore(result.id, backend=tb) == result
Exemplo n.º 5
0
    def test_on_chord_part_return(self, restore):
        tb = CacheBackend(backend='memory://', app=self.app)

        deps = Mock()
        deps.__len__ = Mock()
        deps.__len__.return_value = 2
        restore.return_value = deps
        task = Mock()
        task.name = 'foobarbaz'
        self.app.tasks['foobarbaz'] = task
        task.request.chord = signature(task)

        gid, res = uuid(), [self.app.AsyncResult(uuid()) for _ in range(3)]
        task.request.group = gid
        tb.apply_chord(group(app=self.app), (), gid, {}, result=res)

        self.assertFalse(deps.join_native.called)
        tb.on_chord_part_return(task)
        self.assertFalse(deps.join_native.called)

        tb.on_chord_part_return(task)
        deps.join_native.assert_called_with(propagate=True)
        deps.delete.assert_called_with()
Exemplo n.º 6
0
 def test_apply_chord(self):
     tb = CacheBackend(backend='memory://', app=self.app)
     gid, res = uuid(), [self.app.AsyncResult(uuid()) for _ in range(3)]
     tb.apply_chord(group(app=self.app), (), gid, {}, result=res)
Exemplo n.º 7
0
 def test_apply_chord(self):
     tb = CacheBackend(backend='memory://', app=self.app)
     gid, res = uuid(), [self.app.AsyncResult(uuid()) for _ in range(3)]
     tb.apply_chord(group(app=self.app), (), gid, {}, result=res)