mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Update m* tests to use entity & device registry fixtures (#103980)
This commit is contained in:
committed by
GitHub
parent
51c1ea85f3
commit
9326ea09a5
@ -3050,7 +3050,9 @@ async def test_mqtt_ws_get_device_debug_info_binary(
|
||||
|
||||
|
||||
async def test_debug_info_multiple_devices(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test we get correct debug_info when multiple devices are present."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3097,8 +3099,6 @@ async def test_debug_info_multiple_devices(
|
||||
},
|
||||
]
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
for dev in devices:
|
||||
data = json.dumps(dev["config"])
|
||||
domain = dev["domain"]
|
||||
@ -3109,7 +3109,7 @@ async def test_debug_info_multiple_devices(
|
||||
for dev in devices:
|
||||
domain = dev["domain"]
|
||||
id = dev["config"]["device"]["identifiers"][0]
|
||||
device = registry.async_get_device(identifiers={("mqtt", id)})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", id)})
|
||||
assert device is not None
|
||||
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
@ -3132,7 +3132,9 @@ async def test_debug_info_multiple_devices(
|
||||
|
||||
|
||||
async def test_debug_info_multiple_entities_triggers(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test we get correct debug_info for a device with multiple entities and triggers."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3179,8 +3181,6 @@ async def test_debug_info_multiple_entities_triggers(
|
||||
},
|
||||
]
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
for c in config:
|
||||
data = json.dumps(c["config"])
|
||||
domain = c["domain"]
|
||||
@ -3190,7 +3190,7 @@ async def test_debug_info_multiple_entities_triggers(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device_id = config[0]["config"]["device"]["identifiers"][0]
|
||||
device = registry.async_get_device(identifiers={("mqtt", device_id)})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", device_id)})
|
||||
assert device is not None
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
assert len(debug_info_data["entities"]) == 2
|
||||
@ -3253,7 +3253,9 @@ async def test_debug_info_non_mqtt(
|
||||
|
||||
|
||||
async def test_debug_info_wildcard(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test debug info."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3264,13 +3266,11 @@ async def test_debug_info_wildcard(
|
||||
"unique_id": "veryunique",
|
||||
}
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
data = json.dumps(config)
|
||||
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device = registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
assert device is not None
|
||||
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
@ -3301,7 +3301,9 @@ async def test_debug_info_wildcard(
|
||||
|
||||
|
||||
async def test_debug_info_filter_same(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test debug info removes messages with same timestamp."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3312,13 +3314,11 @@ async def test_debug_info_filter_same(
|
||||
"unique_id": "veryunique",
|
||||
}
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
data = json.dumps(config)
|
||||
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device = registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
assert device is not None
|
||||
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
@ -3361,7 +3361,9 @@ async def test_debug_info_filter_same(
|
||||
|
||||
|
||||
async def test_debug_info_same_topic(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test debug info."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3373,13 +3375,11 @@ async def test_debug_info_same_topic(
|
||||
"unique_id": "veryunique",
|
||||
}
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
data = json.dumps(config)
|
||||
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device = registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
assert device is not None
|
||||
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
@ -3415,7 +3415,9 @@ async def test_debug_info_same_topic(
|
||||
|
||||
|
||||
async def test_debug_info_qos_retain(
|
||||
hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||
) -> None:
|
||||
"""Test debug info."""
|
||||
await mqtt_mock_entry()
|
||||
@ -3426,13 +3428,11 @@ async def test_debug_info_qos_retain(
|
||||
"unique_id": "veryunique",
|
||||
}
|
||||
|
||||
registry = dr.async_get(hass)
|
||||
|
||||
data = json.dumps(config)
|
||||
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device = registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
device = device_registry.async_get_device(identifiers={("mqtt", "helloworld")})
|
||||
assert device is not None
|
||||
|
||||
debug_info_data = debug_info.info_for_device(hass, device.id)
|
||||
|
Reference in New Issue
Block a user