예제 #1
0
파일: test_base.py 프로젝트: bingtel/faust
    async def assert_stop_consumer(self, app):
        consumer = app._consumer = Mock(wait_empty=AsyncMock(), )
        consumer.assignment.return_value = set()
        app.tables = Mock()
        app.flow_control = Mock()
        app._stop_fetcher = AsyncMock()
        await app._stop_consumer()

        consumer.assignment.side_effect = ConsumerNotStarted()
        await app._stop_consumer()

        consumer.assignment.side_effect = None
        assigned = {TP('foo', 0), TP('bar', 1)}
        consumer.assignment.return_value = assigned

        await app._stop_consumer()
        app.tables.on_partitions_revoked.assert_called_once_with(assigned)
        consumer.stop_flow.assert_called_once_with()
        app.flow_control.suspend.assert_called_once_with()
        app._stop_fetcher.assert_called_once_with()
예제 #2
0
 def _ensure_consumer(self) -> aiokafka.AIOKafkaConsumer:
     if self._consumer is None:
         raise ConsumerNotStarted('Consumer thread not yet started')
     return self._consumer