1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Enforce async_load_fixture in async test functions (#145709)

This commit is contained in:
epenet
2025-06-30 11:56:26 +02:00
committed by GitHub
parent 179e1c2b00
commit e642cd45ae
3 changed files with 94 additions and 5 deletions
+13 -5
View File
@@ -9,7 +9,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util import location as location_util
from tests.common import load_fixture
from tests.common import async_load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker
# Paris
@@ -77,10 +77,14 @@ def test_get_miles() -> None:
async def test_detect_location_info_whoami(
aioclient_mock: AiohttpClientMocker, session: aiohttp.ClientSession
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
session: aiohttp.ClientSession,
) -> None:
"""Test detect location info using services.home-assistant.io/whoami."""
aioclient_mock.get(location_util.WHOAMI_URL, text=load_fixture("whoami.json"))
aioclient_mock.get(
location_util.WHOAMI_URL, text=await async_load_fixture(hass, "whoami.json")
)
with patch("homeassistant.util.location.HA_VERSION", "1.0"):
info = await location_util.async_detect_location_info(session, _test_real=True)
@@ -101,10 +105,14 @@ async def test_detect_location_info_whoami(
async def test_dev_url(
aioclient_mock: AiohttpClientMocker, session: aiohttp.ClientSession
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
session: aiohttp.ClientSession,
) -> None:
"""Test usage of dev URL."""
aioclient_mock.get(location_util.WHOAMI_URL_DEV, text=load_fixture("whoami.json"))
aioclient_mock.get(
location_util.WHOAMI_URL_DEV, text=await async_load_fixture(hass, "whoami.json")
)
with patch("homeassistant.util.location.HA_VERSION", "1.0.dev0"):
info = await location_util.async_detect_location_info(session, _test_real=True)