async def test_user_legacy_not_supported(hass): """Test starting a flow by user for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=UnhandledResponse("Boom"), ), patch("homeassistant.components.samsungtv.config_flow.socket"): # legacy device not supported result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA) assert result["type"] == "abort" assert result["reason"] == "not_supported"
async def test_user_legacy_not_supported(hass: HomeAssistant, remote: Mock): """Test starting a flow by user for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=UnhandledResponse("Boom"), ): # legacy device not supported result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA ) assert result["type"] == "abort" assert result["reason"] == RESULT_NOT_SUPPORTED
async def test_autodetect_not_supported(hass, remote): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.config_flow.Remote", side_effect=[UnhandledResponse("Boom")], ) as remote: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA) assert result["type"] == "abort" assert result["reason"] == "not_supported" assert remote.call_count == 1 assert remote.call_args_list == [call(AUTODETECT_WEBSOCKET)]
async def test_autodetect_not_supported(hass: HomeAssistant): """Test for send key with autodetection of protocol.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=[UnhandledResponse("Boom")], ) as remote: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA) assert result["type"] == "abort" assert result["reason"] == RESULT_NOT_SUPPORTED assert remote.call_count == 1 assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
async def test_autodetect_not_supported(opp: OpenPeerPower, remote: Mock): """Test for send key with autodetection of protocol.""" with patch( "openpeerpower.components.samsungtv.bridge.Remote", side_effect=[UnhandledResponse("Boom")], ) as remote, patch( "openpeerpower.components.samsungtv.config_flow.socket.gethostbyname", return_value="fake_host", ): result = await opp.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA) assert result["type"] == "abort" assert result["reason"] == RESULT_NOT_SUPPORTED assert remote.call_count == 1 assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
async def test_ssdp_not_supported(hass): """Test starting a flow from discovery for not supported device.""" with patch( "homeassistant.components.samsungtv.config_flow.Remote", side_effect=UnhandledResponse("Boom"), ), patch("homeassistant.components.samsungtv.config_flow.socket"): # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "ssdp"}, data=MOCK_SSDP_DATA) assert result["type"] == "form" assert result["step_id"] == "confirm" # device not supported result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input="whatever") assert result["type"] == "abort" assert result["reason"] == "not_supported"
async def test_ssdp_legacy_not_supported(hass: HomeAssistant, remote: Mock): """Test starting a flow from discovery for not supported device.""" with patch( "homeassistant.components.samsungtv.bridge.Remote", side_effect=UnhandledResponse("Boom"), ): # confirm to add the entry result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA ) assert result["type"] == "form" assert result["step_id"] == "confirm" # device not supported result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input="whatever" ) assert result["type"] == "abort" assert result["reason"] == RESULT_NOT_SUPPORTED