Fix mqtt check in ozw (#45709)

This commit is contained in:
Martin Hjelmare 2021-01-29 17:57:39 +01:00 committed by GitHub
parent b2789621bd
commit bcc9add0b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 9 deletions

View file

@ -37,6 +37,26 @@ async def test_setup_entry_without_mqtt(hass):
assert not await hass.config_entries.async_setup(entry.entry_id)
async def test_publish_without_mqtt(hass, caplog):
"""Test publish without mqtt integration setup."""
with patch("homeassistant.components.ozw.OZWOptions") as ozw_options:
await setup_ozw(hass)
send_message = ozw_options.call_args[1]["send_message"]
mqtt_entries = hass.config_entries.async_entries("mqtt")
mqtt_entry = mqtt_entries[0]
await hass.config_entries.async_remove(mqtt_entry.entry_id)
await hass.async_block_till_done()
assert not hass.config_entries.async_entries("mqtt")
# Sending a message should not error with the MQTT integration not set up.
send_message("test_topic", "test_payload")
assert "MQTT integration is not set up" in caplog.text
async def test_unload_entry(hass, generic_data, switch_msg, caplog):
"""Test unload the config entry."""
entry = MockConfigEntry(