mirror of
https://github.com/home-assistant/core.git
synced 2026-04-21 00:49:54 +02:00
Mock arguments to ClientResponseError() in miele tests (#156676)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""Tests for Miele button module."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -70,7 +70,7 @@ async def test_api_failure(
|
||||
setup_platform: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(
|
||||
HomeAssistantError, match=f"Failed to set state for {ENTITY_ID}"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for miele climate module."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -108,7 +108,7 @@ async def test_api_failure(
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.set_target_temperature.side_effect = ClientResponseError(
|
||||
"test", "Test"
|
||||
Mock(), Mock()
|
||||
)
|
||||
|
||||
with pytest.raises(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Tests for miele fan module."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -141,7 +141,7 @@ async def test_api_failure(
|
||||
service: str,
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await hass.services.async_call(
|
||||
@@ -156,7 +156,7 @@ async def test_set_percentage(
|
||||
setup_platform: None,
|
||||
) -> None:
|
||||
"""Test handling of exception at set_percentage."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(
|
||||
HomeAssistantError, match=f"Failed to set state for {ENTITY_ID}"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from datetime import timedelta
|
||||
import http
|
||||
import time
|
||||
from unittest.mock import MagicMock, patch
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
from aiohttp import ClientConnectionError, ClientResponseError
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
@@ -215,7 +215,7 @@ async def test_setup_all_platforms(
|
||||
@pytest.mark.parametrize(
|
||||
"side_effect",
|
||||
[
|
||||
ClientResponseError("test", "Test"),
|
||||
ClientResponseError(Mock(), Mock()),
|
||||
TimeoutError,
|
||||
],
|
||||
ids=[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for miele light module."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -84,7 +84,7 @@ async def test_api_failure(
|
||||
service: str,
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(
|
||||
HomeAssistantError, match=f"Failed to set state for {ENTITY_ID}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Tests the services provided by the miele integration."""
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -138,7 +138,7 @@ async def test_service_api_errors(
|
||||
device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_APPLIANCE)})
|
||||
|
||||
# Test http error
|
||||
mock_miele_client.set_program.side_effect = ClientResponseError("TestInfo", "test")
|
||||
mock_miele_client.set_program.side_effect = ClientResponseError(Mock(), Mock())
|
||||
with pytest.raises(HomeAssistantError, match=error):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@@ -162,7 +162,7 @@ async def test_get_service_api_errors(
|
||||
device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_APPLIANCE)})
|
||||
|
||||
# Test http error
|
||||
mock_miele_client.get_programs.side_effect = ClientResponseError("TestInfo", "test")
|
||||
mock_miele_client.get_programs.side_effect = ClientResponseError(Mock(), Mock())
|
||||
with pytest.raises(HomeAssistantError, match="'Get programs' action failed"):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for miele switch module."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
import pytest
|
||||
@@ -99,7 +99,7 @@ async def test_api_failure(
|
||||
entity: str,
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(HomeAssistantError, match=f"Failed to set state for {entity}"):
|
||||
await hass.services.async_call(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Tests for miele vacuum module."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, Mock
|
||||
|
||||
from aiohttp import ClientResponseError
|
||||
from pymiele import MieleDevices
|
||||
@@ -142,7 +142,7 @@ async def test_api_failure(
|
||||
service: str,
|
||||
) -> None:
|
||||
"""Test handling of exception from API."""
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError("test", "Test")
|
||||
mock_miele_client.send_action.side_effect = ClientResponseError(Mock(), Mock())
|
||||
|
||||
with pytest.raises(
|
||||
HomeAssistantError, match=f"Failed to set state for {ENTITY_ID}"
|
||||
|
||||
Reference in New Issue
Block a user