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