mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Improve lists for MQTT integration (#113184)
* Improve lists for MQTT integration * Extra diagnostics tests * Revert changes where the original version was probably faster * Revert change to gather and await in series
This commit is contained in:
@@ -7,7 +7,7 @@ import pytest
|
||||
|
||||
from homeassistant.components import mqtt
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from tests.common import async_fire_mqtt_message
|
||||
from tests.components.diagnostics import (
|
||||
@@ -25,6 +25,7 @@ default_config = {
|
||||
async def test_entry_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
hass_client: ClientSessionGenerator,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
@@ -260,3 +261,28 @@ async def test_redact_diagnostics(
|
||||
"mqtt_config": expected_config,
|
||||
"mqtt_debug_info": expected_debug_info,
|
||||
}
|
||||
|
||||
# Disable the entity and remove the state
|
||||
ent_registry = er.async_get(hass)
|
||||
device_tracker_entry = er.async_entries_for_device(ent_registry, device_entry.id)[0]
|
||||
ent_registry.async_update_entity(
|
||||
device_tracker_entry.entity_id, disabled_by=er.RegistryEntryDisabler.USER
|
||||
)
|
||||
hass.states.async_remove(device_tracker_entry.entity_id)
|
||||
|
||||
# Assert disabled entries are filtered
|
||||
assert await get_diagnostics_for_device(
|
||||
hass, hass_client, config_entry, device_entry
|
||||
) == {
|
||||
"connected": True,
|
||||
"device": {
|
||||
"id": device_entry.id,
|
||||
"name": None,
|
||||
"name_by_user": None,
|
||||
"disabled": False,
|
||||
"disabled_by": None,
|
||||
"entities": [],
|
||||
},
|
||||
"mqtt_config": expected_config,
|
||||
"mqtt_debug_info": {"entities": [], "triggers": []},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user