mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 09:31:51 +02:00
Fix RuntimeWarning in rest tests (#146452)
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import ssl
|
import ssl
|
||||||
from unittest.mock import AsyncMock, MagicMock, patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -174,11 +174,12 @@ async def test_setup_ssl_ciphers(
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
ssl_cipher_list: str,
|
ssl_cipher_list: str,
|
||||||
ssl_cipher_list_expected: SSLCipherList,
|
ssl_cipher_list_expected: SSLCipherList,
|
||||||
|
aioclient_mock: AiohttpClientMocker,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setup with minimum configuration."""
|
"""Test setup with minimum configuration."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.rest.data.async_get_clientsession",
|
"homeassistant.components.rest.data.async_get_clientsession",
|
||||||
return_value=MagicMock(request=AsyncMock(return_value=MagicMock())),
|
return_value=aioclient_mock,
|
||||||
) as aiohttp_client:
|
) as aiohttp_client:
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
|
@ -63,6 +63,7 @@ class AiohttpClientMocker:
|
|||||||
cookies=None,
|
cookies=None,
|
||||||
side_effect=None,
|
side_effect=None,
|
||||||
closing=None,
|
closing=None,
|
||||||
|
timeout=None,
|
||||||
):
|
):
|
||||||
"""Mock a request."""
|
"""Mock a request."""
|
||||||
if not isinstance(url, RETYPE):
|
if not isinstance(url, RETYPE):
|
||||||
@ -70,21 +71,21 @@ class AiohttpClientMocker:
|
|||||||
if params:
|
if params:
|
||||||
url = url.with_query(params)
|
url = url.with_query(params)
|
||||||
|
|
||||||
self._mocks.append(
|
resp = AiohttpClientMockResponse(
|
||||||
AiohttpClientMockResponse(
|
method=method,
|
||||||
method=method,
|
url=url,
|
||||||
url=url,
|
status=status,
|
||||||
status=status,
|
response=content,
|
||||||
response=content,
|
json=json,
|
||||||
json=json,
|
text=text,
|
||||||
text=text,
|
cookies=cookies,
|
||||||
cookies=cookies,
|
exc=exc,
|
||||||
exc=exc,
|
headers=headers,
|
||||||
headers=headers,
|
side_effect=side_effect,
|
||||||
side_effect=side_effect,
|
closing=closing,
|
||||||
closing=closing,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
self._mocks.append(resp)
|
||||||
|
return resp
|
||||||
|
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
"""Register a mock get request."""
|
"""Register a mock get request."""
|
||||||
|
Reference in New Issue
Block a user