File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
tests/components/squeezebox Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 44from unittest .mock import patch
55
66from pysqueezebox import Server
7+ import pytest
78
89from homeassistant import config_entries
910from homeassistant .components .squeezebox .const import (
@@ -96,6 +97,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
9697 assert len (mock_setup_entry .mock_calls ) == 1
9798
9899
100+ @pytest .mark .usefixtures ("mock_setup_entry" )
99101async def test_options_form (hass : HomeAssistant ) -> None :
100102 """Test we can configure options."""
101103 entry = MockConfigEntry (
@@ -605,8 +607,8 @@ async def test_dhcp_discovery_no_server_found(hass: HomeAssistant) -> None:
605607
606608 # Now try to complete the edit step with full schema
607609 with patch (
608- "homeassistant.components.squeezebox.config_flow.async_discover " ,
609- mock_failed_discover ,
610+ "pysqueezebox.Server.async_query " ,
611+ return_value = None ,
610612 ):
611613 result = await hass .config_entries .flow .async_configure (
612614 result ["flow_id" ],
@@ -621,7 +623,7 @@ async def test_dhcp_discovery_no_server_found(hass: HomeAssistant) -> None:
621623
622624 assert result ["type" ] is FlowResultType .FORM
623625 assert result ["step_id" ] == "edit"
624- assert result ["errors" ] == {"base" : "unknown " }
626+ assert result ["errors" ] == {"base" : "cannot_connect " }
625627
626628
627629async def test_dhcp_discovery_existing_player (
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ def squeezebox_media_player_platform():
2626 yield
2727
2828
29+ @pytest .fixture (autouse = True )
30+ def mock_discovery ():
31+ """Mock discovery of squeezebox players."""
32+ with patch ("homeassistant.components.squeezebox.media_player.async_discover" ):
33+ yield
34+
35+
2936async def test_init_api_fail (
3037 hass : HomeAssistant ,
3138 config_entry : MockConfigEntry ,
Original file line number Diff line number Diff line change @@ -86,6 +86,13 @@ def squeezebox_media_player_platform():
8686 yield
8787
8888
89+ @pytest .fixture (autouse = True )
90+ def mock_discovery ():
91+ """Mock discovery of squeezebox players."""
92+ with patch ("homeassistant.components.squeezebox.media_player.async_discover" ):
93+ yield
94+
95+
8996async def test_entity_registry (
9097 hass : HomeAssistant ,
9198 entity_registry : EntityRegistry ,
You can’t perform that action at this time.
0 commit comments