Improve hass type hints for autouse fixtures in tests (#121311)
parent
9383920b1a
commit
4b4b17e774
|
@ -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", {})
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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", {})
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"})
|
||||
|
|
|
@ -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, {})
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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": {}})
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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", {})
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue