Parametrize EMC test

This commit is contained in:
Matthias 2022-10-03 06:39:20 +02:00
parent 9691524ade
commit 4cf4642a6c

View File

@ -188,15 +188,19 @@ async def test_emc_create_connection_success(default_conf, caplog, mocker):
emc.shutdown() emc.shutdown()
async def test_emc_create_connection_invalid_port(default_conf, caplog, mocker): @pytest.mark.parametrize('host,port', [
(_TEST_WS_HOST, -1),
("10000.1241..2121/", _TEST_WS_PORT),
])
async def test_emc_create_connection_invalid_url(default_conf, caplog, mocker, host, port):
default_conf.update({ default_conf.update({
"external_message_consumer": { "external_message_consumer": {
"enabled": True, "enabled": True,
"producers": [ "producers": [
{ {
"name": "default", "name": "default",
"host": _TEST_WS_HOST, "host": host,
"port": -1, "port": port,
"ws_token": _TEST_WS_TOKEN "ws_token": _TEST_WS_TOKEN
} }
], ],
@ -219,34 +223,6 @@ async def test_emc_create_connection_invalid_port(default_conf, caplog, mocker):
emc.shutdown() emc.shutdown()
async def test_emc_create_connection_invalid_host(default_conf, caplog, mocker):
default_conf.update({
"external_message_consumer": {
"enabled": True,
"producers": [
{
"name": "default",
"host": "10000.1241..2121/",
"port": _TEST_WS_PORT,
"ws_token": _TEST_WS_TOKEN
}
],
"wait_timeout": 60,
"ping_timeout": 60,
"sleep_timeout": 60
}
})
dp = DataProvider(default_conf, None, None, None)
emc = ExternalMessageConsumer(default_conf, dp)
try:
await asyncio.sleep(0.01)
assert log_has_re(r".+ is an invalid WebSocket URL .+", caplog)
finally:
emc.shutdown()
async def test_emc_create_connection_error(default_conf, caplog, mocker): async def test_emc_create_connection_error(default_conf, caplog, mocker):
default_conf.update({ default_conf.update({
"external_message_consumer": { "external_message_consumer": {