Use a future for mock coro (#34989)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-04-30 16:31:00 -07:00
1 parent ba7391528f
commit 76f392476b
26 files changed
+154 -262

No files matched your search

+4 -4
View File
@@ -15,7 +15,7 @@ from homeassistant.components.http.view import (
)
from homeassistant.exceptions import ServiceNotFound, Unauthorized
from tests.common import mock_coro_func
from tests.async_mock import AsyncMock
@pytest.fixture
@@ -38,7 +38,7 @@ async def test_handling_unauthorized(mock_request):
"""Test handling unauth exceptions."""
with pytest.raises(HTTPUnauthorized):
await request_handler_factory(
Mock(requires_auth=False), mock_coro_func(exception=Unauthorized)
Mock(requires_auth=False), AsyncMock(side_effect=Unauthorized)
)(mock_request)
@@ -46,7 +46,7 @@ async def test_handling_invalid_data(mock_request):
"""Test handling unauth exceptions."""
with pytest.raises(HTTPBadRequest):
await request_handler_factory(
Mock(requires_auth=False), mock_coro_func(exception=vol.Invalid("yo"))
Mock(requires_auth=False), AsyncMock(side_effect=vol.Invalid("yo"))
)(mock_request)
@@ -55,5 +55,5 @@ async def test_handling_service_not_found(mock_request):
with pytest.raises(HTTPInternalServerError):
await request_handler_factory(
Mock(requires_auth=False),
mock_coro_func(exception=ServiceNotFound("test", "test")),
AsyncMock(side_effect=ServiceNotFound("test", "test")),
)(mock_request)