Bump aiohttp to 3.10.6rc2 (#126468)
parent
450b682c5c
commit
31200040da
|
@ -5,7 +5,7 @@ aiodiscover==2.1.0
|
||||||
aiodns==3.2.0
|
aiodns==3.2.0
|
||||||
aiohasupervisor==0.1.0b1
|
aiohasupervisor==0.1.0b1
|
||||||
aiohttp-fast-zlib==0.1.1
|
aiohttp-fast-zlib==0.1.1
|
||||||
aiohttp==3.10.5
|
aiohttp==3.10.6rc2
|
||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
aiozoneinfo==0.2.1
|
aiozoneinfo==0.2.1
|
||||||
astral==2.2
|
astral==2.2
|
||||||
|
|
|
@ -28,6 +28,19 @@ class MockStreamReader:
|
||||||
return self._content.read(byte_count)
|
return self._content.read(byte_count)
|
||||||
|
|
||||||
|
|
||||||
|
class MockPayloadWriter:
|
||||||
|
"""Small mock to imitate payload writer."""
|
||||||
|
|
||||||
|
def enable_chunking(self) -> None:
|
||||||
|
"""Enable chunking."""
|
||||||
|
|
||||||
|
async def write_headers(self, *args: Any, **kwargs: Any) -> None:
|
||||||
|
"""Write headers."""
|
||||||
|
|
||||||
|
|
||||||
|
_MOCK_PAYLOAD_WRITER = MockPayloadWriter()
|
||||||
|
|
||||||
|
|
||||||
class MockRequest:
|
class MockRequest:
|
||||||
"""Mock an aiohttp request."""
|
"""Mock an aiohttp request."""
|
||||||
|
|
||||||
|
@ -49,8 +62,14 @@ class MockRequest:
|
||||||
self.status = status
|
self.status = status
|
||||||
self.headers: CIMultiDict[str] = CIMultiDict(headers or {})
|
self.headers: CIMultiDict[str] = CIMultiDict(headers or {})
|
||||||
self.query_string = query_string or ""
|
self.query_string = query_string or ""
|
||||||
|
self.keep_alive = False
|
||||||
|
self.version = (1, 1)
|
||||||
self._content = content
|
self._content = content
|
||||||
self.mock_source = mock_source
|
self.mock_source = mock_source
|
||||||
|
self._payload_writer = _MOCK_PAYLOAD_WRITER
|
||||||
|
|
||||||
|
async def _prepare_hook(self, response: Any) -> None:
|
||||||
|
"""Prepare hook."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def query(self) -> MultiDict[str]:
|
def query(self) -> MultiDict[str]:
|
||||||
|
@ -90,7 +109,7 @@ def serialize_response(response: web.Response) -> dict[str, Any]:
|
||||||
if (body := response.body) is None:
|
if (body := response.body) is None:
|
||||||
body_decoded = None
|
body_decoded = None
|
||||||
elif isinstance(body, payload.StringPayload):
|
elif isinstance(body, payload.StringPayload):
|
||||||
body_decoded = body._value.decode(body.encoding) # noqa: SLF001
|
body_decoded = body._value.decode(body.encoding or "utf-8") # noqa: SLF001
|
||||||
elif isinstance(body, bytes):
|
elif isinstance(body, bytes):
|
||||||
body_decoded = body.decode(response.charset or "utf-8")
|
body_decoded = body.decode(response.charset or "utf-8")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -27,7 +27,7 @@ dependencies = [
|
||||||
# Integrations may depend on hassio integration without listing it to
|
# Integrations may depend on hassio integration without listing it to
|
||||||
# change behavior based on presence of supervisor
|
# change behavior based on presence of supervisor
|
||||||
"aiohasupervisor==0.1.0b1",
|
"aiohasupervisor==0.1.0b1",
|
||||||
"aiohttp==3.10.5",
|
"aiohttp==3.10.6rc2",
|
||||||
"aiohttp_cors==0.7.0",
|
"aiohttp_cors==0.7.0",
|
||||||
"aiohttp-fast-zlib==0.1.1",
|
"aiohttp-fast-zlib==0.1.1",
|
||||||
"aiozoneinfo==0.2.1",
|
"aiozoneinfo==0.2.1",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
# Home Assistant Core
|
# Home Assistant Core
|
||||||
aiodns==3.2.0
|
aiodns==3.2.0
|
||||||
aiohasupervisor==0.1.0b1
|
aiohasupervisor==0.1.0b1
|
||||||
aiohttp==3.10.5
|
aiohttp==3.10.6rc2
|
||||||
aiohttp_cors==0.7.0
|
aiohttp_cors==0.7.0
|
||||||
aiohttp-fast-zlib==0.1.1
|
aiohttp-fast-zlib==0.1.1
|
||||||
aiozoneinfo==0.2.1
|
aiozoneinfo==0.2.1
|
||||||
|
|
|
@ -298,10 +298,20 @@ async def test_enqueue_alert_exclusive(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"media_content_id",
|
||||||
|
[
|
||||||
|
"a/b c/d+e%2Fg{}",
|
||||||
|
"a/b c/d+e%2D",
|
||||||
|
"a/b c/d+e%2E",
|
||||||
|
"2012-06%20Pool%20party%20%2F%20BBQ",
|
||||||
|
],
|
||||||
|
)
|
||||||
async def test_get_async_get_browse_image_quoting(
|
async def test_get_async_get_browse_image_quoting(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client_no_auth: ClientSessionGenerator,
|
hass_client_no_auth: ClientSessionGenerator,
|
||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
|
media_content_id: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test get browse image using media_content_id with special characters.
|
"""Test get browse image using media_content_id with special characters.
|
||||||
|
|
||||||
|
@ -325,7 +335,6 @@ async def test_get_async_get_browse_image_quoting(
|
||||||
"homeassistant.components.media_player.MediaPlayerEntity."
|
"homeassistant.components.media_player.MediaPlayerEntity."
|
||||||
"async_get_browse_image",
|
"async_get_browse_image",
|
||||||
) as mock_browse_image:
|
) as mock_browse_image:
|
||||||
media_content_id = "a/b c/d+e%2Fg{}"
|
|
||||||
url = player.get_browse_image_url("album", media_content_id)
|
url = player.get_browse_image_url("album", media_content_id)
|
||||||
await client.get(url)
|
await client.get(url)
|
||||||
mock_browse_image.assert_called_with("album", media_content_id, None)
|
mock_browse_image.assert_called_with("album", media_content_id, None)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
from asyncio import AbstractEventLoop
|
from asyncio import AbstractEventLoop
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
import copy
|
import copy
|
||||||
from typing import cast
|
|
||||||
from unittest.mock import AsyncMock, Mock, call
|
from unittest.mock import AsyncMock, Mock, call
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
@ -46,6 +45,7 @@ from homeassistant.const import ATTR_DEVICE_ID, ATTR_ENTITY_ID, CONF_URL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
from homeassistant.util.aiohttp import MockRequest
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
|
@ -231,7 +231,7 @@ async def test_get_still_image_from_camera(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting a still image."""
|
"""Test getting a still image."""
|
||||||
|
|
||||||
image_handler = AsyncMock(return_value="")
|
image_handler = AsyncMock(return_value=web.Response(body=""))
|
||||||
|
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
app.add_routes(
|
app.add_routes(
|
||||||
|
@ -273,7 +273,8 @@ async def test_get_stream_from_camera(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test getting a stream."""
|
"""Test getting a stream."""
|
||||||
|
|
||||||
stream_handler = AsyncMock(return_value="")
|
stream_handler = AsyncMock(return_value=web.Response(body=""))
|
||||||
|
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
app.add_routes([web.get("/", stream_handler)])
|
app.add_routes([web.get("/", stream_handler)])
|
||||||
stream_server = await aiohttp_server(app)
|
stream_server = await aiohttp_server(app)
|
||||||
|
@ -297,12 +298,7 @@ async def test_get_stream_from_camera(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# It won't actually get a stream from the dummy handler, so just catch
|
await async_get_mjpeg_stream(hass, MockRequest(b"", "test"), TEST_CAMERA_ENTITY_ID)
|
||||||
# the expected exception, then verify the right handler was called.
|
|
||||||
with pytest.raises(HTTPBadGateway):
|
|
||||||
await async_get_mjpeg_stream(
|
|
||||||
hass, cast(web.Request, None), TEST_CAMERA_ENTITY_ID
|
|
||||||
)
|
|
||||||
assert stream_handler.called
|
assert stream_handler.called
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,7 +354,8 @@ async def test_camera_option_stream_url_template(
|
||||||
"""Verify camera with a stream URL template option."""
|
"""Verify camera with a stream URL template option."""
|
||||||
client = create_mock_motioneye_client()
|
client = create_mock_motioneye_client()
|
||||||
|
|
||||||
stream_handler = AsyncMock(return_value="")
|
stream_handler = AsyncMock(return_value=web.Response(body=""))
|
||||||
|
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
app.add_routes([web.get(f"/{TEST_CAMERA_NAME}/{TEST_CAMERA_ID}", stream_handler)])
|
app.add_routes([web.get(f"/{TEST_CAMERA_NAME}/{TEST_CAMERA_ID}", stream_handler)])
|
||||||
stream_server = await aiohttp_server(app)
|
stream_server = await aiohttp_server(app)
|
||||||
|
@ -384,10 +381,7 @@ async def test_camera_option_stream_url_template(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
# It won't actually get a stream from the dummy handler, so just catch
|
await async_get_mjpeg_stream(hass, MockRequest(b"", "test"), TEST_CAMERA_ENTITY_ID)
|
||||||
# the expected exception, then verify the right handler was called.
|
|
||||||
with pytest.raises(HTTPBadGateway):
|
|
||||||
await async_get_mjpeg_stream(hass, Mock(), TEST_CAMERA_ENTITY_ID)
|
|
||||||
assert AsyncMock.called
|
assert AsyncMock.called
|
||||||
assert not client.get_camera_stream_url.called
|
assert not client.get_camera_stream_url.called
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from collections.abc import Iterator
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import re
|
import re
|
||||||
|
from types import TracebackType
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
@ -166,7 +167,7 @@ class AiohttpClientMockResponse:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
method,
|
method,
|
||||||
url,
|
url: URL,
|
||||||
status=HTTPStatus.OK,
|
status=HTTPStatus.OK,
|
||||||
response=None,
|
response=None,
|
||||||
json=None,
|
json=None,
|
||||||
|
@ -297,6 +298,18 @@ class AiohttpClientMockResponse:
|
||||||
raise ClientConnectionError("Connection closed")
|
raise ClientConnectionError("Connection closed")
|
||||||
return self._response
|
return self._response
|
||||||
|
|
||||||
|
async def __aenter__(self):
|
||||||
|
"""Enter the context manager."""
|
||||||
|
return self
|
||||||
|
|
||||||
|
async def __aexit__(
|
||||||
|
self,
|
||||||
|
exc_type: type[BaseException] | None,
|
||||||
|
exc_val: BaseException | None,
|
||||||
|
exc_tb: TracebackType | None,
|
||||||
|
) -> None:
|
||||||
|
"""Exit the context manager."""
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def mock_aiohttp_client() -> Iterator[AiohttpClientMocker]:
|
def mock_aiohttp_client() -> Iterator[AiohttpClientMocker]:
|
||||||
|
|
Loading…
Reference in New Issue