Improve hass type hints for autouse fixtures in tests (#121311)

pull/121313/head
epenet 2024-07-05 16:49:22 +02:00 committed by GitHub
parent 9383920b1a
commit 4b4b17e774
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 16 additions and 15 deletions

View File

@ -8,7 +8,7 @@ from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
async def setup_media_source(hass):
async def setup_media_source(hass: HomeAssistant) -> None:
"""Set up media source."""
assert await async_setup_component(hass, "media_source", {})

View File

@ -19,7 +19,7 @@ def mock_load_json():
@pytest.fixture(autouse=True)
def mock_dependencies(hass):
def mock_dependencies(hass: HomeAssistant) -> None:
"""Mock dependencies loaded."""
mock_component(hass, "zeroconf")
mock_component(hass, "device_tracker")

View File

@ -67,7 +67,7 @@ async def webhook_client(
@pytest.fixture(autouse=True)
async def setup_ws(hass):
async def setup_ws(hass: HomeAssistant) -> None:
"""Configure the websocket_api component."""
assert await async_setup_component(hass, "repairs", {})
assert await async_setup_component(hass, "websocket_api", {})

View File

@ -18,7 +18,7 @@ from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
def init_sensors_fixture(hass):
def init_sensors_fixture(hass: HomeAssistant) -> None:
"""Set up things to be run when tests are started."""
hass.states.async_set(
"test.indoortemp", "20", {ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS}

View File

@ -109,7 +109,7 @@ async def auth(aiohttp_client: ClientSessionGenerator) -> FakeAuth:
@pytest.fixture(autouse=True)
def cleanup_media_storage(hass):
def cleanup_media_storage(hass: HomeAssistant) -> Generator[None]:
"""Test cleanup, remove any media storage persisted during the test."""
tmp_path = str(uuid.uuid4())
with patch("homeassistant.components.nest.media_source.MEDIA_PATH", new=tmp_path):

View File

@ -28,7 +28,7 @@ from tests.typing import ClientSessionGenerator
@pytest.fixture(autouse=True)
def auth_active(hass):
def auth_active(hass: HomeAssistant) -> None:
"""Ensure auth is always active."""
hass.loop.run_until_complete(
register_auth_provider(hass, {"type": "homeassistant"})

View File

@ -3,10 +3,11 @@
import pytest
import homeassistant.components.persistent_notification as pn
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@pytest.fixture(autouse=True)
async def setup_integration(hass):
async def setup_integration(hass: HomeAssistant) -> None:
"""Set up persistent notification integration."""
assert await async_setup_component(hass, pn.DOMAIN, {})

View File

@ -12,7 +12,7 @@ from tests.common import assert_setup_component, mock_component
@pytest.fixture(autouse=True)
def setup_comp(hass):
def setup_comp(hass: HomeAssistant) -> None:
"""Initialize components."""
mock_component(hass, "pilight")

View File

@ -115,7 +115,7 @@ class MockFixFlowAbort(RepairsFlow):
@pytest.fixture(autouse=True)
async def mock_repairs_integration(hass):
async def mock_repairs_integration(hass: HomeAssistant) -> None:
"""Mock a repairs integration."""
hass.config.components.add("fake_integration")

View File

@ -35,7 +35,7 @@ from tests.common import async_fire_time_changed
@pytest.fixture(autouse=True)
async def stream_component(hass):
async def stream_component(hass: HomeAssistant) -> None:
"""Set up the component before each test."""
await async_setup_component(hass, "stream", {"stream": {}})

View File

@ -83,7 +83,7 @@ def filename(tmp_path: Path) -> str:
@pytest.fixture(autouse=True)
def mock_stream_settings(hass):
def mock_stream_settings(hass: HomeAssistant) -> None:
"""Set the stream settings data in hass before each test."""
hass.data[DOMAIN] = {
ATTR_SETTINGS: StreamSettings(

View File

@ -27,7 +27,7 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
@pytest.fixture(autouse=True)
def setup_comp(hass):
def setup_comp(hass: HomeAssistant) -> None:
"""Initialize components."""
mock_component(hass, "group")
hass.loop.run_until_complete(

View File

@ -45,7 +45,7 @@ async def traccar_client(
@pytest.fixture(autouse=True)
async def setup_zones(hass):
async def setup_zones(hass: HomeAssistant) -> None:
"""Set up Zone config in HA."""
assert await async_setup_component(
hass,

View File

@ -17,7 +17,7 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
@pytest.fixture(autouse=True)
async def setup_http(hass):
async def setup_http(hass: HomeAssistant) -> None:
"""Set up http."""
assert await async_setup_component(hass, "http", {})
assert await async_setup_component(hass, "webhook", {})

View File

@ -17,7 +17,7 @@ def stub_blueprint_populate_autouse(stub_blueprint_populate: None) -> None:
@pytest.fixture(autouse=True)
def setup_comp(hass):
def setup_comp(hass: HomeAssistant) -> None:
"""Initialize components."""
mock_component(hass, "group")
hass.loop.run_until_complete(