Beispiel #1
0
async def test_snmp_error(opp):
    """Test SNMP error."""
    with patch("brother.Brother._get_data", side_effect=SnmpError("error")):
        result = await opp.config_entries.flow.async_init(
            DOMAIN, context={"source": SOURCE_USER}, data=CONFIG)

        assert result["errors"] == {"base": "snmp_error"}
Beispiel #2
0
async def test_snmp_error(hass):
    """Test SNMP error."""
    with patch("brother.Brother._get_data", side_effect=SnmpError("error")):
        flow = config_flow.BrotherConfigFlow()
        flow.hass = hass

        result = await hass.config_entries.flow.async_init(
            DOMAIN, context={"source": "user"}, data=CONFIG
        )

        assert result["errors"] == {"base": "snmp_error"}
Beispiel #3
0
async def test_snmp_error():
    """Test with raise SnmpError."""
    brother = Brother(HOST)

    with patch("brother.Brother._init_device",
               side_effect=SnmpError("SNMP Error")):
        try:
            await brother.async_update()
        except SnmpError as error:
            assert str(error.status) == "SNMP Error"

    brother.shutdown()
async def test_zeroconf_snmp_error(hass):
    """Test we abort zeroconf flow on SNMP error."""
    with patch("brother.Brother._get_data", side_effect=SnmpError("error")):

        result = await hass.config_entries.flow.async_init(
            DOMAIN,
            context={"source": SOURCE_ZEROCONF},
            data={"hostname": "example.local.", "name": "Brother Printer"},
        )

        assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
        assert result["reason"] == "cannot_connect"
Beispiel #5
0
async def test_zeroconf_snmp_error(hass):
    """Test we abort zeroconf flow on SNMP error."""
    with patch("brother.Brother._get_data", side_effect=SnmpError("error")):

        result = await hass.config_entries.flow.async_init(
            DOMAIN,
            context={"source": SOURCE_ZEROCONF},
            data=zeroconf.ZeroconfServiceInfo(
                host="mock_host",
                hostname="example.local.",
                name="Brother Printer",
                port=None,
                properties={},
                type="mock_type",
            ),
        )

        assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
        assert result["reason"] == "cannot_connect"