Replace deprecated aiohttp_unused_port fixture (#97626)
This commit is contained in:
parent
91a83e1ad2
commit
887e48c440
2 changed files with 14 additions and 12 deletions
|
@ -85,11 +85,13 @@ class TestView(http.HomeAssistantView):
|
||||||
|
|
||||||
|
|
||||||
async def test_registering_view_while_running(
|
async def test_registering_view_while_running(
|
||||||
hass: HomeAssistant, aiohttp_client: ClientSessionGenerator, aiohttp_unused_port
|
hass: HomeAssistant, aiohttp_client: ClientSessionGenerator, unused_tcp_port_factory
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we can register a view while the server is running."""
|
"""Test that we can register a view while the server is running."""
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass, http.DOMAIN, {http.DOMAIN: {http.CONF_SERVER_PORT: aiohttp_unused_port()}}
|
hass,
|
||||||
|
http.DOMAIN,
|
||||||
|
{http.DOMAIN: {http.CONF_SERVER_PORT: unused_tcp_port_factory()}},
|
||||||
)
|
)
|
||||||
|
|
||||||
await hass.async_start()
|
await hass.async_start()
|
||||||
|
@ -443,11 +445,11 @@ async def test_cors_defaults(hass: HomeAssistant) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def test_storing_config(
|
async def test_storing_config(
|
||||||
hass: HomeAssistant, aiohttp_client: ClientSessionGenerator, aiohttp_unused_port
|
hass: HomeAssistant, aiohttp_client: ClientSessionGenerator, unused_tcp_port_factory
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that we store last working config."""
|
"""Test that we store last working config."""
|
||||||
config = {
|
config = {
|
||||||
http.CONF_SERVER_PORT: aiohttp_unused_port(),
|
http.CONF_SERVER_PORT: unused_tcp_port_factory(),
|
||||||
"use_x_forwarded_for": True,
|
"use_x_forwarded_for": True,
|
||||||
"trusted_proxies": ["192.168.1.100"],
|
"trusted_proxies": ["192.168.1.100"],
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ async def setup_homeassistant(hass: HomeAssistant):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def aiohttp_unused_port(event_loop, aiohttp_unused_port, socket_enabled):
|
def aiohttp_unused_port_factory(event_loop, unused_tcp_port_factory, socket_enabled):
|
||||||
"""Return aiohttp_unused_port and allow opening sockets."""
|
"""Return aiohttp_unused_port and allow opening sockets."""
|
||||||
return aiohttp_unused_port
|
return unused_tcp_port_factory
|
||||||
|
|
||||||
|
|
||||||
def get_url(hass):
|
def get_url(hass):
|
||||||
|
@ -34,12 +34,12 @@ def get_url(hass):
|
||||||
return f"{hass.config.internal_url}{state.attributes.get(ATTR_ENTITY_PICTURE)}"
|
return f"{hass.config.internal_url}{state.attributes.get(ATTR_ENTITY_PICTURE)}"
|
||||||
|
|
||||||
|
|
||||||
async def setup_image_processing(hass, aiohttp_unused_port):
|
async def setup_image_processing(hass, aiohttp_unused_port_factory):
|
||||||
"""Set up things to be run when tests are started."""
|
"""Set up things to be run when tests are started."""
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
http.DOMAIN,
|
http.DOMAIN,
|
||||||
{http.DOMAIN: {http.CONF_SERVER_PORT: aiohttp_unused_port()}},
|
{http.DOMAIN: {http.CONF_SERVER_PORT: aiohttp_unused_port_factory()}},
|
||||||
)
|
)
|
||||||
|
|
||||||
config = {ip.DOMAIN: {"platform": "test"}, "camera": {"platform": "demo"}}
|
config = {ip.DOMAIN: {"platform": "test"}, "camera": {"platform": "demo"}}
|
||||||
|
@ -85,11 +85,11 @@ async def test_setup_component_with_service(hass: HomeAssistant) -> None:
|
||||||
async def test_get_image_from_camera(
|
async def test_get_image_from_camera(
|
||||||
mock_camera_read,
|
mock_camera_read,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aiohttp_unused_port,
|
aiohttp_unused_port_factory,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Grab an image from camera entity."""
|
"""Grab an image from camera entity."""
|
||||||
await setup_image_processing(hass, aiohttp_unused_port)
|
await setup_image_processing(hass, aiohttp_unused_port_factory)
|
||||||
|
|
||||||
common.async_scan(hass, entity_id="image_processing.test")
|
common.async_scan(hass, entity_id="image_processing.test")
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -108,11 +108,11 @@ async def test_get_image_from_camera(
|
||||||
async def test_get_image_without_exists_camera(
|
async def test_get_image_without_exists_camera(
|
||||||
mock_image,
|
mock_image,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aiohttp_unused_port,
|
aiohttp_unused_port_factory,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Try to get image without exists camera."""
|
"""Try to get image without exists camera."""
|
||||||
await setup_image_processing(hass, aiohttp_unused_port)
|
await setup_image_processing(hass, aiohttp_unused_port_factory)
|
||||||
|
|
||||||
hass.states.async_remove("camera.demo_camera")
|
hass.states.async_remove("camera.demo_camera")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue