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

Method test_create_task_handler

t/unit/worker/test_consumer.py:355–382  ·  view source on GitHub ↗
(self, subtests)

Source from the content-addressed store, hash-verified

353 assert c._restore_prefetch_count_after_connection_restart(None) is None
354
355 def test_create_task_handler(self, subtests):
356 c = self.get_consumer()
357 c.qos = MagicMock()
358 c.qos.value = 1
359 c._maximum_prefetch_restored = False
360
361 sig = self.add.s(2, 2)
362 message = self.task_message_from_sig(self.app, sig)
363
364 def raise_exception(*args, **kwargs):
365 raise KeyError('Foo')
366
367 def strategy(_, __, ack_log_error_promise, ___, ____):
368 ack_log_error_promise()
369
370 c.strategies[sig.task] = strategy
371 c.call_soon_ack = raise_exception
372 on_task_received = c.create_task_handler()
373 on_task_received(message)
374
375 with subtests.test("initial prefetch count is never 0"):
376 assert c.initial_prefetch_count != 0
377
378 with subtests.test("initial prefetch count is 2"):
379 assert c.initial_prefetch_count == 2
380
381 with subtests.test("maximum prefetch is reached"):
382 assert c._maximum_prefetch_restored is True
383
384 def test_flush_events(self):
385 c = self.get_consumer()

Callers

nothing calls this directly

Calls 4

create_task_handlerMethod · 0.80
testMethod · 0.80
get_consumerMethod · 0.45
sMethod · 0.45

Tested by

no test coverage detected