コード例 #1
0
async def test_user_websocket_not_supported(hass: HomeAssistant,
                                            remotews: Mock):
    """Test starting a flow by user for not supported device."""
    with patch(
            "homeassistant.components.samsungtv.bridge.Remote",
            side_effect=OSError("Boom"),
    ), patch(
            "homeassistant.components.samsungtv.bridge.SamsungTVWS",
            side_effect=WebSocketProtocolException("Boom"),
    ):
        # websocket 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
コード例 #2
0
async def test_ssdp_not_supported_2(hass):
    """Test starting a flow from discovery for not supported device."""
    with patch(
            "homeassistant.components.samsungtv.config_flow.Remote",
            side_effect=WebSocketProtocolException("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"
コード例 #3
0
async def test_ssdp_websocket_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=OSError("Boom"),
    ), patch(
        "homeassistant.components.samsungtv.bridge.SamsungTVWS",
        side_effect=WebSocketProtocolException("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