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 + )