webstat-collector/tests/test_consumer.py

20 lines
494 B
Python
Raw Normal View History

import asyncio
import pytest
2020-09-09 00:27:40 +02:00
from mock import AsyncMock, Mock, patch
from chweb.consumer import Consumer
@pytest.mark.asyncio
2020-09-06 10:51:10 +02:00
@patch('ssl.SSLContext')
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()
task.cancel()