Add and use HTTP_FORBIDDEN constant (#33839)

This commit is contained in:
springstan 2020-04-09 17:41:17 +02:00 committed by GitHub
parent 70ee9d7f26
commit bc26be3c11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 60 additions and 37 deletions

View file

@ -7,7 +7,13 @@ from asynctest import patch
from homeassistant import data_entry_flow
from homeassistant.components.airly.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.const import (
CONF_API_KEY,
CONF_LATITUDE,
CONF_LONGITUDE,
CONF_NAME,
HTTP_FORBIDDEN,
)
from tests.common import MockConfigEntry, load_fixture
@ -33,7 +39,9 @@ async def test_invalid_api_key(hass):
"""Test that errors are shown when API key is invalid."""
with patch(
"airly._private._RequestsHandler.get",
side_effect=AirlyError(403, {"message": "Invalid authentication credentials"}),
side_effect=AirlyError(
HTTP_FORBIDDEN, {"message": "Invalid authentication credentials"}
),
):
result = await hass.config_entries.flow.async_init(