Ensure coverage mqtt entry disabled test (#101617)
This commit is contained in:
parent
3bbef476ee
commit
74464fd94e
1 changed files with 15 additions and 8 deletions
|
@ -3545,15 +3545,16 @@ async def test_publish_or_subscribe_without_valid_config_entry(
|
||||||
await mqtt.async_subscribe(hass, "some-topic", record_calls, qos=0)
|
await mqtt.async_subscribe(hass, "some-topic", record_calls, qos=0)
|
||||||
|
|
||||||
|
|
||||||
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT])
|
@patch(
|
||||||
|
"homeassistant.components.mqtt.PLATFORMS",
|
||||||
|
["tag", Platform.LIGHT],
|
||||||
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"hass_config",
|
"hass_config",
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"mqtt": {
|
"mqtt": {
|
||||||
"light": [
|
"light": [{"name": "test", "command_topic": "test-topic"}],
|
||||||
{"name": "test_new_modern", "command_topic": "test-topic_new"}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -3567,9 +3568,11 @@ async def test_disabling_and_enabling_entry(
|
||||||
await mqtt_mock_entry()
|
await mqtt_mock_entry()
|
||||||
entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
|
entry = hass.config_entries.async_entries(mqtt.DOMAIN)[0]
|
||||||
assert entry.state is ConfigEntryState.LOADED
|
assert entry.state is ConfigEntryState.LOADED
|
||||||
# Late discovery of a light
|
# Late discovery of a mqtt entity/tag
|
||||||
config = '{"name": "abc", "command_topic": "test-topic"}'
|
config_tag = '{"topic": "0AFFD2/tag_scanned", "value_template": "{{ value_json.PN532.UID }}"}'
|
||||||
async_fire_mqtt_message(hass, "homeassistant/light/abc/config", config)
|
config_light = '{"name": "test2", "command_topic": "test-topic_new"}'
|
||||||
|
async_fire_mqtt_message(hass, "homeassistant/tag/abc/config", config_tag)
|
||||||
|
async_fire_mqtt_message(hass, "homeassistant/light/abc/config", config_light)
|
||||||
|
|
||||||
# Disable MQTT config entry
|
# Disable MQTT config entry
|
||||||
await hass.config_entries.async_set_disabled_by(
|
await hass.config_entries.async_set_disabled_by(
|
||||||
|
@ -3578,6 +3581,10 @@ async def test_disabling_and_enabling_entry(
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
assert (
|
||||||
|
"MQTT integration is disabled, skipping setup of discovered item MQTT tag"
|
||||||
|
in caplog.text
|
||||||
|
)
|
||||||
assert (
|
assert (
|
||||||
"MQTT integration is disabled, skipping setup of discovered item MQTT light"
|
"MQTT integration is disabled, skipping setup of discovered item MQTT light"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
|
@ -3593,7 +3600,7 @@ async def test_disabling_and_enabling_entry(
|
||||||
new_mqtt_config_entry = entry
|
new_mqtt_config_entry = entry
|
||||||
assert new_mqtt_config_entry.state is ConfigEntryState.LOADED
|
assert new_mqtt_config_entry.state is ConfigEntryState.LOADED
|
||||||
|
|
||||||
assert hass.states.get("light.test_new_modern") is not None
|
assert hass.states.get("light.test") is not None
|
||||||
|
|
||||||
|
|
||||||
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT])
|
@patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT])
|
||||||
|
|
Loading…
Add table
Reference in a new issue