mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use HTTPStatus instead of HTTP_ consts and magic values in components/a* (#57988)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Tests for the Abode config flow."""
|
||||
from http import HTTPStatus
|
||||
from unittest.mock import patch
|
||||
|
||||
from abodepy.exceptions import AbodeAuthenticationException
|
||||
@@ -8,12 +9,7 @@ from homeassistant import data_entry_flow
|
||||
from homeassistant.components.abode import config_flow
|
||||
from homeassistant.components.abode.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
HTTP_BAD_REQUEST,
|
||||
HTTP_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -56,7 +52,9 @@ async def test_invalid_credentials(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.abode.config_flow.Abode",
|
||||
side_effect=AbodeAuthenticationException((HTTP_BAD_REQUEST, "auth error")),
|
||||
side_effect=AbodeAuthenticationException(
|
||||
(HTTPStatus.BAD_REQUEST, "auth error")
|
||||
),
|
||||
):
|
||||
result = await flow.async_step_user(user_input=conf)
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
@@ -72,7 +70,7 @@ async def test_connection_error(hass):
|
||||
with patch(
|
||||
"homeassistant.components.abode.config_flow.Abode",
|
||||
side_effect=AbodeAuthenticationException(
|
||||
(HTTP_INTERNAL_SERVER_ERROR, "connection error")
|
||||
(HTTPStatus.INTERNAL_SERVER_ERROR, "connection error")
|
||||
),
|
||||
):
|
||||
result = await flow.async_step_user(user_input=conf)
|
||||
@@ -117,7 +115,9 @@ async def test_step_mfa(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.abode.config_flow.Abode",
|
||||
side_effect=AbodeAuthenticationException((HTTP_BAD_REQUEST, "invalid mfa")),
|
||||
side_effect=AbodeAuthenticationException(
|
||||
(HTTPStatus.BAD_REQUEST, "invalid mfa")
|
||||
),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"mfa_code": "123456"}
|
||||
|
||||
Reference in New Issue
Block a user