mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Add missing hass type in tests/*.py (#124048)
This commit is contained in:
@@ -18,6 +18,7 @@ from syrupy.assertion import SnapshotAssertion
|
||||
from homeassistant import config_entries, data_entry_flow, loader
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.hassio import HassioServiceInfo
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
EVENT_COMPONENT_LOADED,
|
||||
EVENT_HOMEASSISTANT_STARTED,
|
||||
@@ -104,12 +105,12 @@ async def test_setup_race_only_setup_once(hass: HomeAssistant) -> None:
|
||||
fast_config_entry_setup_future = hass.loop.create_future()
|
||||
slow_setup_future = hass.loop.create_future()
|
||||
|
||||
async def async_setup(hass, config):
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock setup."""
|
||||
await slow_setup_future
|
||||
return True
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry."""
|
||||
slow = entry.data["slow"]
|
||||
if slow:
|
||||
@@ -122,7 +123,7 @@ async def test_setup_race_only_setup_once(hass: HomeAssistant) -> None:
|
||||
await fast_config_entry_setup_future
|
||||
return True
|
||||
|
||||
async def async_unload_entry(hass, entry):
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock unload entry."""
|
||||
return True
|
||||
|
||||
@@ -582,7 +583,7 @@ async def test_remove_entry_raises(
|
||||
) -> None:
|
||||
"""Test if a component raises while removing entry."""
|
||||
|
||||
async def mock_unload_entry(hass, entry):
|
||||
async def mock_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock unload entry function."""
|
||||
raise Exception("BROKEN") # noqa: TRY002
|
||||
|
||||
@@ -1326,7 +1327,7 @@ async def test_update_entry_options_and_trigger_listener(
|
||||
entry.add_to_manager(manager)
|
||||
update_listener_calls = []
|
||||
|
||||
async def update_listener(hass, entry):
|
||||
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||
"""Test function."""
|
||||
assert entry.options == {"second": True}
|
||||
update_listener_calls.append(None)
|
||||
@@ -1491,7 +1492,7 @@ async def test_reload_during_setup_retrying_waits(hass: HomeAssistant) -> None:
|
||||
load_attempts = []
|
||||
sleep_duration = 0
|
||||
|
||||
async def _mock_setup_entry(hass, entry):
|
||||
async def _mock_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry."""
|
||||
nonlocal sleep_duration
|
||||
await asyncio.sleep(sleep_duration)
|
||||
@@ -1536,7 +1537,7 @@ async def test_create_entry_options(
|
||||
) -> None:
|
||||
"""Test a config entry being created with options."""
|
||||
|
||||
async def mock_async_setup(hass, config):
|
||||
async def mock_async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock setup."""
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
@@ -3234,7 +3235,7 @@ async def test_async_setup_init_entry_completes_before_loaded_event_fires(
|
||||
"""Test a config entry being initialized during integration setup before the loaded event fires."""
|
||||
load_events = async_capture_events(hass, EVENT_COMPONENT_LOADED)
|
||||
|
||||
async def mock_async_setup(hass, config):
|
||||
async def mock_async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock setup."""
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
@@ -3292,7 +3293,7 @@ async def test_async_setup_update_entry(hass: HomeAssistant) -> None:
|
||||
entry = MockConfigEntry(domain="comp", data={"value": "initial"})
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def mock_async_setup(hass, config):
|
||||
async def mock_async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Mock setup."""
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
@@ -3303,7 +3304,7 @@ async def test_async_setup_update_entry(hass: HomeAssistant) -> None:
|
||||
)
|
||||
return True
|
||||
|
||||
async def mock_async_setup_entry(hass, entry):
|
||||
async def mock_async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setting up an entry."""
|
||||
assert entry.data["value"] == "updated"
|
||||
return True
|
||||
@@ -3791,7 +3792,7 @@ async def test_setup_raise_entry_error_from_first_coordinator_update(
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry with a simple coordinator."""
|
||||
|
||||
async def _async_update_data():
|
||||
@@ -3831,7 +3832,7 @@ async def test_setup_not_raise_entry_error_from_future_coordinator_update(
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry with a simple coordinator."""
|
||||
|
||||
async def _async_update_data():
|
||||
@@ -3910,7 +3911,7 @@ async def test_setup_raise_auth_failed_from_first_coordinator_update(
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry with a simple coordinator."""
|
||||
|
||||
async def _async_update_data():
|
||||
@@ -3962,7 +3963,7 @@ async def test_setup_raise_auth_failed_from_future_coordinator_update(
|
||||
entry = MockConfigEntry(title="test_title", domain="test")
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
async def async_setup_entry(hass, entry):
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setup entry with a simple coordinator."""
|
||||
|
||||
async def _async_update_data():
|
||||
@@ -4409,12 +4410,12 @@ async def test_unique_id_update_while_setup_in_progress(
|
||||
) -> None:
|
||||
"""Test we handle the case where the config entry is updated while setup is in progress."""
|
||||
|
||||
async def mock_setup_entry(hass, entry):
|
||||
async def mock_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setting up entry."""
|
||||
await asyncio.sleep(0.1)
|
||||
return True
|
||||
|
||||
async def mock_unload_entry(hass, entry):
|
||||
async def mock_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock unloading an entry."""
|
||||
return True
|
||||
|
||||
@@ -5463,7 +5464,7 @@ async def test_reload_during_setup(hass: HomeAssistant) -> None:
|
||||
in_setup = False
|
||||
setup_calls = 0
|
||||
|
||||
async def mock_async_setup_entry(hass, entry):
|
||||
async def mock_async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Mock setting up an entry."""
|
||||
nonlocal in_setup
|
||||
nonlocal setup_calls
|
||||
|
||||
Reference in New Issue
Block a user