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

Method test_loop

t/unit/worker/test_worker.py:360–388  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

358 c.loop(*c.loop_args())
359
360 def test_loop(self):
361
362 class Connection(self.app.connection_for_read().__class__):
363 obj = None
364
365 def drain_events(self, **kwargs):
366 self.obj.connection = None
367
368 @property
369 def supports_heartbeats(self):
370 return False
371
372 c = self.LoopConsumer()
373 c.blueprint.state = RUN
374 c.connection = Connection(self.app.conf.broker_url)
375 c.connection.obj = c
376 c.connection.get_heartbeat_interval = Mock(return_value=None)
377 c.qos = QoS(c.task_consumer.qos, 10)
378
379 c.loop(*c.loop_args())
380 c.loop(*c.loop_args())
381 assert c.task_consumer.consume.call_count
382 c.task_consumer.qos.assert_called_with(prefetch_count=10)
383 assert c.qos.value == 10
384 c.qos.decrement_eventually()
385 assert c.qos.value == 9
386 c.qos.update()
387 assert c.qos.value == 9
388 c.task_consumer.qos.assert_called_with(prefetch_count=9)
389
390 def test_ignore_errors(self):
391 c = self.NoopConsumer()

Callers

nothing calls this directly

Calls 5

LoopConsumerMethod · 0.95
loopMethod · 0.80
loop_argsMethod · 0.80
ConnectionClass · 0.70
updateMethod · 0.45

Tested by

no test coverage detected