MQTT convert to async (#6064)
* Migrate mqtt to async * address paulus comment / convert it complet async * adress paulus comment / remove future * Automation triggers should be async * Fix MQTT async calls * Show that event helpers are callbacks * Fix tests * Lint
This commit is contained in:
1 parent
fa2c1dafdf
commit
e1cbd6b4c0
25 files changed
+356
-231
No files matched your search
@@ -12,9 +12,10 @@ def test_subscribing_config_topic(hass, mqtt_mock):
|
||||
"""Test setting up discovery."""
|
||||
hass_config = {}
|
||||
discovery_topic = 'homeassistant'
|
||||
async_start(hass, discovery_topic, hass_config)
|
||||
assert mqtt_mock.subscribe.called
|
||||
call_args = mqtt_mock.subscribe.mock_calls[0][1]
|
||||
yield from async_start(hass, discovery_topic, hass_config)
|
||||
|
||||
assert mqtt_mock.async_subscribe.called
|
||||
call_args = mqtt_mock.async_subscribe.mock_calls[0][1]
|
||||
assert call_args[0] == discovery_topic + '/#'
|
||||
assert call_args[1] == 0
|
||||
|
||||
@@ -24,7 +25,7 @@ def test_subscribing_config_topic(hass, mqtt_mock):
|
||||
def test_invalid_topic(mock_load_platform, hass, mqtt_mock):
|
||||
"""Test sending in invalid JSON."""
|
||||
mock_load_platform.return_value = mock_coro()
|
||||
async_start(hass, 'homeassistant', {})
|
||||
yield from async_start(hass, 'homeassistant', {})
|
||||
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/not_config',
|
||||
'{}')
|
||||
@@ -37,7 +38,7 @@ def test_invalid_topic(mock_load_platform, hass, mqtt_mock):
|
||||
def test_invalid_json(mock_load_platform, hass, mqtt_mock, caplog):
|
||||
"""Test sending in invalid JSON."""
|
||||
mock_load_platform.return_value = mock_coro()
|
||||
async_start(hass, 'homeassistant', {})
|
||||
yield from async_start(hass, 'homeassistant', {})
|
||||
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
|
||||
'not json')
|
||||
@@ -51,7 +52,7 @@ def test_invalid_json(mock_load_platform, hass, mqtt_mock, caplog):
|
||||
def test_only_valid_components(mock_load_platform, hass, mqtt_mock, caplog):
|
||||
"""Test sending in invalid JSON."""
|
||||
mock_load_platform.return_value = mock_coro()
|
||||
async_start(hass, 'homeassistant', {})
|
||||
yield from async_start(hass, 'homeassistant', {})
|
||||
|
||||
async_fire_mqtt_message(hass, 'homeassistant/climate/bla/config', '{}')
|
||||
yield from hass.async_block_till_done()
|
||||
@@ -62,7 +63,7 @@ def test_only_valid_components(mock_load_platform, hass, mqtt_mock, caplog):
|
||||
@asyncio.coroutine
|
||||
def test_correct_config_discovery(hass, mqtt_mock, caplog):
|
||||
"""Test sending in invalid JSON."""
|
||||
async_start(hass, 'homeassistant', {})
|
||||
yield from async_start(hass, 'homeassistant', {})
|
||||
|
||||
async_fire_mqtt_message(hass, 'homeassistant/binary_sensor/bla/config',
|
||||
'{ "name": "Beer" }')
|
||||
|
||||
Reference in new issue
Block a user