From 9fa3f8cfac991f751581d29cbc18cb0334eb0f53 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Sun, 25 Jan 2026 19:26:42 +0100 Subject: [PATCH] Add 100% coverage to init for Fritz (#161583) --- tests/components/fritz/test_init.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/components/fritz/test_init.py b/tests/components/fritz/test_init.py index de69e0b5914..956e4f6037c 100644 --- a/tests/components/fritz/test_init.py +++ b/tests/components/fritz/test_init.py @@ -102,3 +102,28 @@ async def test_setup_fail(hass: HomeAssistant, error) -> None: await hass.async_block_till_done() assert entry.state is ConfigEntryState.SETUP_RETRY + + +async def test_upnp_missing( + hass: HomeAssistant, caplog: pytest.LogCaptureFixture, fc_class_mock, fh_class_mock +) -> None: + """Test UPNP configuration is missing.""" + + entry = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_DATA) + entry.add_to_hass(hass) + + with ( + patch( + "homeassistant.components.fritz.coordinator.AvmWrapper.async_get_upnp_configuration", + return_value={"NewEnable": False}, + ), + ): + await hass.config_entries.async_setup(entry.entry_id) + await hass.async_block_till_done() + + assert entry.state is ConfigEntryState.SETUP_ERROR + assert entry.state.recoverable is True + assert ( + "Config entry 'Mock Title' for fritz integration could not authenticate: Missing UPnP configuration" + in caplog.text + )