Use HTTP_BAD_REQUEST constant (#33797)

This commit is contained in:
springstan authored and GitHub committed 2020-04-09 21:43:42 +02:00
1 parent d510384c0d
commit 4c38e6cfa5
24 files changed
+111 -61

No files matched your search

@@ -13,7 +13,7 @@ from homeassistant.components.alexa import (
errors as alexa_errors,
state_report as alexa_state_report,
)
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES, HTTP_BAD_REQUEST
from homeassistant.core import callback
from homeassistant.helpers import entity_registry
from homeassistant.helpers.event import async_call_later
@@ -114,7 +114,7 @@ class AlexaConfig(alexa_config.AbstractConfig):
resp = await cloud_api.async_alexa_access_token(self._cloud)
body = await resp.json()
if resp.status == 400:
if resp.status == HTTP_BAD_REQUEST:
if body["reason"] in ("RefreshTokenNotFound", "UnknownRegion"):
if self.should_report_state:
await self._prefs.async_update(alexa_report_state=False)
+11 -5
View File
@@ -19,7 +19,7 @@ from homeassistant.components.google_assistant import helpers as google_helpers
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.components.websocket_api import const as ws_const
from homeassistant.const import HTTP_INTERNAL_SERVER_ERROR, HTTP_OK
from homeassistant.const import HTTP_BAD_REQUEST, HTTP_INTERNAL_SERVER_ERROR, HTTP_OK
from homeassistant.core import callback
from .const import (
@@ -109,11 +109,17 @@ async def async_setup(hass):
_CLOUD_ERRORS.update(
{
auth.UserNotFound: (400, "User does not exist."),
auth.UserNotConfirmed: (400, "Email not confirmed."),
auth.UserExists: (400, "An account with the given email already exists."),
auth.UserNotFound: (HTTP_BAD_REQUEST, "User does not exist."),
auth.UserNotConfirmed: (HTTP_BAD_REQUEST, "Email not confirmed."),
auth.UserExists: (
HTTP_BAD_REQUEST,
"An account with the given email already exists.",
),
auth.Unauthenticated: (401, "Authentication failed."),
auth.PasswordChangeRequired: (400, "Password change required."),
auth.PasswordChangeRequired: (
HTTP_BAD_REQUEST,
"Password change required.",
),
asyncio.TimeoutError: (502, "Unable to reach the Home Assistant cloud."),
aiohttp.ClientError: (
HTTP_INTERNAL_SERVER_ERROR,