From 0fcbfa996f4921210cf536896ecf9f086d006291 Mon Sep 17 00:00:00 2001 From: "Phill (pssc)" Date: Thu, 10 Oct 2024 16:38:14 +0100 Subject: [PATCH] Add squeezebox API failure test (#128066) * add api failure test * Update tests/components/squeezebox/test_init.py --------- Co-authored-by: Joost Lekkerkerker --- tests/components/squeezebox/test_init.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/components/squeezebox/test_init.py diff --git a/tests/components/squeezebox/test_init.py b/tests/components/squeezebox/test_init.py new file mode 100644 index 00000000000..9074f57cdcb --- /dev/null +++ b/tests/components/squeezebox/test_init.py @@ -0,0 +1,23 @@ +"""Test squeezebox initialization.""" + +from unittest.mock import patch + +from homeassistant.core import HomeAssistant + +from tests.common import MockConfigEntry + + +async def test_init_api_fail( + hass: HomeAssistant, + config_entry: MockConfigEntry, +) -> None: + """Test init fail due to API fail.""" + + # Setup component to fail... + with ( + patch( + "homeassistant.components.squeezebox.Server.async_query", + return_value=False, + ), + ): + assert not await hass.config_entries.async_setup(config_entry.entry_id)