Bump aiohttp to 3.10.6rc2 (#126468)
parent
450b682c5c
commit
31200040da
|
@ -5,7 +5,7 @@ aiodiscover==2.1.0
|
|||
aiodns==3.2.0
|
||||
aiohasupervisor==0.1.0b1
|
||||
aiohttp-fast-zlib==0.1.1
|
||||
aiohttp==3.10.5
|
||||
aiohttp==3.10.6rc2
|
||||
aiohttp_cors==0.7.0
|
||||
aiozoneinfo==0.2.1
|
||||
astral==2.2
|
||||
|
|
|
@ -28,6 +28,19 @@ class MockStreamReader:
|
|||
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:
|
||||
"""Mock an aiohttp request."""
|
||||
|
||||
|
@ -49,8 +62,14 @@ class MockRequest:
|
|||
self.status = status
|
||||
self.headers: CIMultiDict[str] = CIMultiDict(headers or {})
|
||||
self.query_string = query_string or ""
|
||||
self.keep_alive = False
|
||||
self.version = (1, 1)
|
||||
self._content = content
|
||||
self.mock_source = mock_source
|
||||
self._payload_writer = _MOCK_PAYLOAD_WRITER
|
||||
|
||||
async def _prepare_hook(self, response: Any) -> None:
|
||||
"""Prepare hook."""
|
||||
|
||||
@property
|
||||
def query(self) -> MultiDict[str]:
|
||||
|
@ -90,7 +109,7 @@ def serialize_response(response: web.Response) -> dict[str, Any]:
|
|||
if (body := response.body) is None:
|
||||
body_decoded = None
|
||||
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):
|
||||
body_decoded = body.decode(response.charset or "utf-8")
|
||||
else:
|
||||
|
|
|
@ -27,7 +27,7 @@ dependencies = [
|
|||
# Integrations may depend on hassio integration without listing it to
|
||||
# change behavior based on presence of supervisor
|
||||
"aiohasupervisor==0.1.0b1",
|
||||
"aiohttp==3.10.5",
|
||||
"aiohttp==3.10.6rc2",
|
||||
"aiohttp_cors==0.7.0",
|
||||
"aiohttp-fast-zlib==0.1.1",
|
||||
"aiozoneinfo==0.2.1",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
# Home Assistant Core
|
||||
aiodns==3.2.0
|
||||
aiohasupervisor==0.1.0b1
|
||||
aiohttp==3.10.5
|
||||
aiohttp==3.10.6rc2
|
||||
aiohttp_cors==0.7.0
|
||||
aiohttp-fast-zlib==0.1.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(
|
||||
hass: HomeAssistant,
|
||||
hass_client_no_auth: ClientSessionGenerator,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
media_content_id: str,
|
||||
) -> None:
|
||||
"""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."
|
||||
"async_get_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)
|
||||
await client.get(url)
|
||||
mock_browse_image.assert_called_with("album", media_content_id, None)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from asyncio import AbstractEventLoop
|
||||
from collections.abc import Callable
|
||||
import copy
|
||||
from typing import cast
|
||||
from unittest.mock import AsyncMock, Mock, call
|
||||
|
||||
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.exceptions import HomeAssistantError
|
||||
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
|
||||
|
||||
from . import (
|
||||
|
@ -231,7 +231,7 @@ async def test_get_still_image_from_camera(
|
|||
) -> None:
|
||||
"""Test getting a still image."""
|
||||
|
||||
image_handler = AsyncMock(return_value="")
|
||||
image_handler = AsyncMock(return_value=web.Response(body=""))
|
||||
|
||||
app = web.Application()
|
||||
app.add_routes(
|
||||
|
@ -273,7 +273,8 @@ async def test_get_stream_from_camera(
|
|||
) -> None:
|
||||
"""Test getting a stream."""
|
||||
|
||||
stream_handler = AsyncMock(return_value="")
|
||||
stream_handler = AsyncMock(return_value=web.Response(body=""))
|
||||
|
||||
app = web.Application()
|
||||
app.add_routes([web.get("/", stream_handler)])
|
||||
stream_server = await aiohttp_server(app)
|
||||
|
@ -297,12 +298,7 @@ async def test_get_stream_from_camera(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# It won't actually get a stream from the dummy handler, so just catch
|
||||
# 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
|
||||
)
|
||||
await async_get_mjpeg_stream(hass, MockRequest(b"", "test"), TEST_CAMERA_ENTITY_ID)
|
||||
assert stream_handler.called
|
||||
|
||||
|
||||
|
@ -358,7 +354,8 @@ async def test_camera_option_stream_url_template(
|
|||
"""Verify camera with a stream URL template option."""
|
||||
client = create_mock_motioneye_client()
|
||||
|
||||
stream_handler = AsyncMock(return_value="")
|
||||
stream_handler = AsyncMock(return_value=web.Response(body=""))
|
||||
|
||||
app = web.Application()
|
||||
app.add_routes([web.get(f"/{TEST_CAMERA_NAME}/{TEST_CAMERA_ID}", stream_handler)])
|
||||
stream_server = await aiohttp_server(app)
|
||||
|
@ -384,10 +381,7 @@ async def test_camera_option_stream_url_template(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# It won't actually get a stream from the dummy handler, so just catch
|
||||
# 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)
|
||||
await async_get_mjpeg_stream(hass, MockRequest(b"", "test"), TEST_CAMERA_ENTITY_ID)
|
||||
assert AsyncMock.called
|
||||
assert not client.get_camera_stream_url.called
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from collections.abc import Iterator
|
|||
from contextlib import contextmanager
|
||||
from http import HTTPStatus
|
||||
import re
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from unittest import mock
|
||||
from urllib.parse import parse_qs
|
||||
|
@ -166,7 +167,7 @@ class AiohttpClientMockResponse:
|
|||
def __init__(
|
||||
self,
|
||||
method,
|
||||
url,
|
||||
url: URL,
|
||||
status=HTTPStatus.OK,
|
||||
response=None,
|
||||
json=None,
|
||||
|
@ -297,6 +298,18 @@ class AiohttpClientMockResponse:
|
|||
raise ClientConnectionError("Connection closed")
|
||||
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
|
||||
def mock_aiohttp_client() -> Iterator[AiohttpClientMocker]:
|
||||
|
|
Loading…
Reference in New Issue