From 2d65454cdbc58566a02646bdb8870c00a6a1f6ca Mon Sep 17 00:00:00 2001 From: Marc-Olivier Arsenault Date: Fri, 16 Aug 2024 11:34:30 +0000 Subject: [PATCH] add tests for missing data --- tests/test_sensor.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 5f3022e..57393e6 100755 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -390,6 +390,31 @@ async def test_multi_mcu_sensor_data(hass, get_data, get_printer_objects_list): ) +async def test_multi_mcu_sensor_missing_data(hass, get_data, get_printer_objects_list): + """Test.""" + get_printer_objects_list["objects"].append("mcu Extruder") + get_data["status"]["mcu Extruder"] = { + "last_stats": None, + } + + config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test") + config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(config_entry.entry_id) + await hass.async_block_till_done() + + registry = get_entity_registry(hass) + + assert ( + registry.async_get_entity_id("sensor", DOMAIN, "test_mcu_Extruder_load") + is not None + ) + + assert ( + registry.async_get_entity_id("sensor", DOMAIN, "test_mcu_Extruder_awake") + is not None + ) + + async def test_rounding_fan(hass, get_data): """Test.""" get_data["status"]["fan"]["speed"] = 0.33333333333