async def test_form_cannot_connect(opp): """Test we handle cannot connect error.""" result = await opp.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "openpeerpower.components.tesla.config_flow.TeslaAPI.connect", side_effect=TeslaException(code=404), ): result2 = await opp.config_entries.flow.async_configure( result["flow_id"], {CONF_PASSWORD: "******", CONF_USERNAME: "******"}, ) assert result2["type"] == "form" assert result2["errors"] == {"base": "connection_error"}
async def test_form_invalid_auth(opp): """Test we handle invalid auth.""" result = await opp.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "openpeerpower.components.tesla.config_flow.TeslaAPI.connect", side_effect=TeslaException(401), ): result2 = await opp.config_entries.flow.async_configure( result["flow_id"], {CONF_USERNAME: "******", CONF_PASSWORD: "******"}, ) assert result2["type"] == "form" assert result2["errors"] == {"base": "invalid_credentials"}