Mock SSLContext in the unit tests
This commit is contained in:
parent
f9bfc8a2d1
commit
8239cf11da
3 changed files with 14 additions and 2 deletions
|
@ -10,6 +10,10 @@ def config():
|
|||
'kafka': {
|
||||
'servers': ["localhost:9992"],
|
||||
'topic': "sample",
|
||||
'cafile': "/dev/null",
|
||||
'cert': "/dev/null",
|
||||
'key': "/dev/null",
|
||||
'passwd': "",
|
||||
},
|
||||
'postgres': {
|
||||
'dbhost': "localhost",
|
||||
|
@ -34,6 +38,10 @@ def config_invalid():
|
|||
'kafka': {
|
||||
'servers': ["localhost:9992"],
|
||||
'topic': "sample",
|
||||
'cafile': "",
|
||||
'cert': "",
|
||||
'key': "",
|
||||
'passwd': "",
|
||||
},
|
||||
'postgres': {
|
||||
'dbhost': "localhost",
|
||||
|
@ -41,6 +49,7 @@ def config_invalid():
|
|||
'dbname': "chweb",
|
||||
'dbuser': "vladan",
|
||||
'dbpass': "",
|
||||
'dbcert': "",
|
||||
},
|
||||
'sites': [{
|
||||
'url': "https://dsadakjhkjsahkjh.com",
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import asyncio
|
||||
|
||||
import aiokafka
|
||||
from mock import Mock, AsyncMock
|
||||
from mock import AsyncMock, Mock, patch
|
||||
import pytest
|
||||
|
||||
from chweb.consumer import Consumer
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch('ssl.SSLContext')
|
||||
async def test_consumer_called(check, config, event_loop):
|
||||
consumer = Consumer(config, Mock(), event_loop, Mock())
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import asyncio
|
||||
|
||||
import aiokafka
|
||||
from mock import Mock, AsyncMock
|
||||
from mock import AsyncMock, Mock, patch
|
||||
import pytest
|
||||
|
||||
from chweb.collector import Producer
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch('ssl.SSLContext')
|
||||
async def test_producer_called(check, config, event_loop):
|
||||
queue = asyncio.Queue()
|
||||
producer = Producer(config, Mock(), event_loop, queue)
|
||||
|
@ -23,6 +24,7 @@ async def test_producer_called(check, config, event_loop):
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch('ssl.SSLContext')
|
||||
async def test_producer_called_invalid(config, event_loop):
|
||||
queue = asyncio.Queue()
|
||||
producer = Producer(config, Mock(), event_loop, queue)
|
||||
|
|
Loading…
Reference in a new issue