Drop use of async_mock_mqtt_component (#37011)

This commit is contained in:
Erik Montnemery 2020-06-22 23:59:50 +02:00 committed by GitHub
parent a2e2c35011
commit 280f49540e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 126 additions and 209 deletions

View file

@ -6,12 +6,7 @@ import pytest
import homeassistant.components.automation as automation
from homeassistant.setup import async_setup_component
from tests.common import (
async_fire_mqtt_message,
async_mock_mqtt_component,
async_mock_service,
mock_component,
)
from tests.common import async_fire_mqtt_message, async_mock_service, mock_component
from tests.components.automation import common
@ -22,10 +17,9 @@ def calls(hass):
@pytest.fixture(autouse=True)
def setup_comp(hass):
def setup_comp(hass, mqtt_mock):
"""Initialize components."""
mock_component(hass, "group")
hass.loop.run_until_complete(async_mock_mqtt_component(hass))
async def test_if_fires_on_topic_match(hass, calls):
@ -104,10 +98,8 @@ async def test_if_not_fires_on_topic_but_no_payload_match(hass, calls):
assert len(calls) == 0
async def test_encoding_default(hass, calls):
async def test_encoding_default(hass, calls, mqtt_mock):
"""Test default encoding."""
mock_mqtt = await async_mock_mqtt_component(hass)
assert await async_setup_component(
hass,
automation.DOMAIN,
@ -119,15 +111,13 @@ async def test_encoding_default(hass, calls):
},
)
mock_mqtt.async_subscribe.assert_called_once_with(
mqtt_mock.async_subscribe.assert_called_once_with(
"test-topic", mock.ANY, 0, "utf-8"
)
async def test_encoding_custom(hass, calls):
async def test_encoding_custom(hass, calls, mqtt_mock):
"""Test default encoding."""
mock_mqtt = await async_mock_mqtt_component(hass)
assert await async_setup_component(
hass,
automation.DOMAIN,
@ -139,4 +129,4 @@ async def test_encoding_custom(hass, calls):
},
)
mock_mqtt.async_subscribe.assert_called_once_with("test-topic", mock.ANY, 0, None)
mqtt_mock.async_subscribe.assert_called_once_with("test-topic", mock.ANY, 0, None)