From b7230a88da739191a142af403bad089a3fe43528 Mon Sep 17 00:00:00 2001 From: darkrain-nl Date: Wed, 14 Oct 2026 07:06:13 +0200 Subject: [PATCH] Test the Sofar clock result sensor on PV inverters (#186159) --- tests/components/sofar/test_button.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/components/sofar/test_button.py b/tests/components/sofar/test_button.py index 1e59dc68cd08..1977a95d7a42 100644 --- a/tests/components/sofar/test_button.py +++ b/tests/components/sofar/test_button.py @@ -109,22 +109,31 @@ async def test_button_press( assert connection.for_unit(1).holding[register] == 1 +@pytest.mark.parametrize( + ("serial", "model", "seed"), + [ + pytest.param(MOCK_SERIAL, MOCK_MODEL, seed_pv_inverter, id="pv"), + pytest.param( + MOCK_HYBRID_SERIAL, MOCK_HYBRID_MODEL, seed_hybrid_inverter, id="hybrid" + ), + ], +) async def test_rtc_sync_reported_to_hass( - hass: HomeAssistant, entity_registry: er.EntityRegistry + hass: HomeAssistant, + entity_registry: er.EntityRegistry, + serial: str, + model: str, + seed: Callable[[MockModbusUnit], None], ) -> None: """Test the RTC sync result reaches its sensor after the refresh.""" await _setup( - hass, - MOCK_HYBRID_SERIAL, - MOCK_HYBRID_MODEL, - seed_hybrid_inverter, - platforms=(Platform.BUTTON, Platform.SENSOR), + hass, serial, model, seed, platforms=(Platform.BUTTON, Platform.SENSOR) ) button_id = entity_registry.async_get_entity_id( - BUTTON_DOMAIN, DOMAIN, f"{MOCK_HYBRID_SERIAL}_rtc_sync" + BUTTON_DOMAIN, DOMAIN, f"{serial}_rtc_sync" ) result_id = entity_registry.async_get_entity_id( - SENSOR_DOMAIN, DOMAIN, f"{MOCK_HYBRID_SERIAL}_sync_rtc_result" + SENSOR_DOMAIN, DOMAIN, f"{serial}_sync_rtc_result" ) assert button_id is not None assert result_id is not None