MQTT discovery (#5724)
* Change implementation * Re-write * Remove unused consts * Update discovery.py * Add tests * fix other tests * Fix check_config script test * Lint * Lint
This commit is contained in:
parent
45507cd9d1
commit
c7fd28c10f
7 changed files with 213 additions and 11 deletions
|
@ -1,12 +1,14 @@
|
|||
"""Setup some common test helper things."""
|
||||
import functools
|
||||
import logging
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import requests_mock as _requests_mock
|
||||
|
||||
from homeassistant import util
|
||||
from homeassistant import util, bootstrap
|
||||
from homeassistant.util import location
|
||||
from homeassistant.components import mqtt
|
||||
|
||||
from .common import async_test_home_assistant
|
||||
from .test_util.aiohttp import mock_aiohttp_client
|
||||
|
@ -58,3 +60,18 @@ def aioclient_mock():
|
|||
"""Fixture to mock aioclient calls."""
|
||||
with mock_aiohttp_client() as mock_session:
|
||||
yield mock_session
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mqtt_mock(loop, hass):
|
||||
"""Fixture to mock MQTT."""
|
||||
with patch('homeassistant.components.mqtt.MQTT') as mock_mqtt:
|
||||
loop.run_until_complete(bootstrap.async_setup_component(
|
||||
hass, mqtt.DOMAIN, {
|
||||
mqtt.DOMAIN: {
|
||||
mqtt.CONF_BROKER: 'mock-broker',
|
||||
}
|
||||
}))
|
||||
client = mock_mqtt()
|
||||
client.reset_mock()
|
||||
return client
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue