Use HTTPStatus instead of HTTP_* constants in various test mocks (#56543)

This commit is contained in:
Ville Skyttä 2021-10-02 01:52:45 +03:00 committed by GitHub
parent e5b0bbcca6
commit 2730a27fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 59 deletions

View file

@ -1,4 +1,5 @@
"""Tests for the SmartThings component init module."""
from http import HTTPStatus
from unittest.mock import Mock, patch
from uuid import uuid4
@ -19,7 +20,6 @@ from homeassistant.components.smartthings.const import (
SIGNAL_SMARTTHINGS_UPDATE,
)
from homeassistant.config import async_process_ha_core_config
from homeassistant.const import HTTP_FORBIDDEN, HTTP_INTERNAL_SERVER_ERROR
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.setup import async_setup_component
@ -83,7 +83,9 @@ async def test_recoverable_api_errors_raise_not_ready(
config_entry.add_to_hass(hass)
request_info = Mock(real_url="http://example.com")
smartthings_mock.app.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_INTERNAL_SERVER_ERROR
request_info=request_info,
history=None,
status=HTTPStatus.INTERNAL_SERVER_ERROR,
)
with pytest.raises(ConfigEntryNotReady):
@ -99,7 +101,9 @@ async def test_scenes_api_errors_raise_not_ready(
smartthings_mock.app.return_value = app
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.scenes.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_INTERNAL_SERVER_ERROR
request_info=request_info,
history=None,
status=HTTPStatus.INTERNAL_SERVER_ERROR,
)
with pytest.raises(ConfigEntryNotReady):
await smartthings.async_setup_entry(hass, config_entry)
@ -160,7 +164,7 @@ async def test_scenes_unauthorized_loads_platforms(
smartthings_mock.installed_app.return_value = installed_app
smartthings_mock.devices.return_value = [device]
smartthings_mock.scenes.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_FORBIDDEN
request_info=request_info, history=None, status=HTTPStatus.FORBIDDEN
)
mock_token = Mock()
mock_token.access_token = str(uuid4())
@ -311,10 +315,10 @@ async def test_remove_entry_already_deleted(hass, config_entry, smartthings_mock
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_FORBIDDEN
request_info=request_info, history=None, status=HTTPStatus.FORBIDDEN
)
smartthings_mock.delete_app.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_FORBIDDEN
request_info=request_info, history=None, status=HTTPStatus.FORBIDDEN
)
# Act
await smartthings.async_remove_entry(hass, config_entry)
@ -330,7 +334,9 @@ async def test_remove_entry_installedapp_api_error(
request_info = Mock(real_url="http://example.com")
# Arrange
smartthings_mock.delete_installed_app.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_INTERNAL_SERVER_ERROR
request_info=request_info,
history=None,
status=HTTPStatus.INTERNAL_SERVER_ERROR,
)
# Act
with pytest.raises(ClientResponseError):
@ -359,7 +365,9 @@ async def test_remove_entry_app_api_error(hass, config_entry, smartthings_mock):
# Arrange
request_info = Mock(real_url="http://example.com")
smartthings_mock.delete_app.side_effect = ClientResponseError(
request_info=request_info, history=None, status=HTTP_INTERNAL_SERVER_ERROR
request_info=request_info,
history=None,
status=HTTPStatus.INTERNAL_SERVER_ERROR,
)
# Act
with pytest.raises(ClientResponseError):