2020-09-06 03:18:52 +02:00
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
|
|
|
2020-09-09 00:27:40 +02:00
|
|
|
from mock import AsyncMock, Mock, patch
|
2020-09-06 03:18:52 +02:00
|
|
|
from chweb.consumer import Consumer
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.asyncio
|
2020-09-06 10:51:10 +02:00
|
|
|
@patch('ssl.SSLContext')
|
2020-09-06 03:18:52 +02:00
|
|
|
async def test_consumer_called(check, config, event_loop):
|
|
|
|
consumer = Consumer(config, Mock(), event_loop, Mock())
|
|
|
|
|
|
|
|
consumer.consumer = AsyncMock()
|
|
|
|
|
|
|
|
task = event_loop.create_task(consumer())
|
|
|
|
await asyncio.sleep(0)
|
|
|
|
consumer.consumer.start.assert_called()
|
2020-09-09 00:27:40 +02:00
|
|
|
consumer.consumer.__aiter__.assert_called()
|
2020-09-06 03:18:52 +02:00
|
|
|
task.cancel()
|