MCPcopy Create free account
hub / github.com/celery/celery / test_replace_callback

Method test_replace_callback

t/unit/tasks/test_tasks.py:1434–1457  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1432 self.mytask.replace(sig1)
1433
1434 def test_replace_callback(self):
1435 c = group([self.mytask.s()], app=self.app)
1436 c.freeze = Mock(name='freeze')
1437 c.delay = Mock(name='delay')
1438 self.mytask.request.id = 'id'
1439 self.mytask.request.group = 'group'
1440 self.mytask.request.root_id = 'root_id'
1441 self.mytask.request.callbacks = callbacks = 'callbacks'
1442 self.mytask.request.errbacks = errbacks = 'errbacks'
1443
1444 # Replacement groups get uplifted to chords so that we can accumulate
1445 # the results and link call/errbacks - patch the appropriate `chord`
1446 # methods so we can validate this behaviour
1447 with patch(
1448 "celery.canvas.chord.link"
1449 ) as mock_chord_link, patch(
1450 "celery.canvas.chord.link_error"
1451 ) as mock_chord_link_error:
1452 with pytest.raises(Ignore):
1453 self.mytask.replace(c)
1454 # Confirm that the call/errbacks on the original signature are linked
1455 # to the replacement signature as expected
1456 mock_chord_link.assert_called_once_with(callbacks)
1457 mock_chord_link_error.assert_called_once_with(errbacks)
1458
1459 def test_replace_group(self):
1460 c = group([self.mytask.s()], app=self.app)

Callers

nothing calls this directly

Calls 4

groupClass · 0.90
raisesMethod · 0.80
sMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected