Improve type hints in device_tracker tests (#120390)

This commit is contained in:
epenet 2024-06-25 10:06:38 +02:00 committed by GitHub
parent 7f20c1a489
commit f8d5c9144a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View File

@ -43,7 +43,7 @@ def calls(hass: HomeAssistant) -> list[ServiceCall]:
@pytest.fixture(autouse=True)
def setup_zone(hass):
def setup_zone(hass: HomeAssistant) -> None:
"""Create test zone."""
hass.loop.run_until_complete(
async_setup_component(

View File

@ -8,6 +8,7 @@ from types import ModuleType
from unittest.mock import call, patch
import pytest
from typing_extensions import Generator
from homeassistant.components import device_tracker, zone
from homeassistant.components.device_tracker import SourceType, const, legacy
@ -49,7 +50,7 @@ _LOGGER = logging.getLogger(__name__)
@pytest.fixture(name="yaml_devices")
def mock_yaml_devices(hass):
def mock_yaml_devices(hass: HomeAssistant) -> Generator[str]:
"""Get a path for storing yaml devices."""
yaml_devices = hass.config.path(legacy.YAML_DEVICES)
if os.path.isfile(yaml_devices):
@ -108,7 +109,7 @@ async def test_reading_broken_yaml_config(hass: HomeAssistant) -> None:
assert res[0].dev_id == "my_device"
async def test_reading_yaml_config(hass: HomeAssistant, yaml_devices) -> None:
async def test_reading_yaml_config(hass: HomeAssistant, yaml_devices: str) -> None:
"""Test the rendering of the YAML configuration."""
dev_id = "test"
device = legacy.Device(
@ -186,7 +187,7 @@ async def test_duplicate_mac_dev_id(mock_warning, hass: HomeAssistant) -> None:
assert "Duplicate device IDs" in args[0], "Duplicate device IDs warning expected"
async def test_setup_without_yaml_file(hass: HomeAssistant, yaml_devices) -> None:
async def test_setup_without_yaml_file(hass: HomeAssistant, yaml_devices: str) -> None:
"""Test with no YAML file."""
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
@ -487,7 +488,7 @@ async def test_invalid_dev_id(
assert not devices
async def test_see_state(hass: HomeAssistant, yaml_devices) -> None:
async def test_see_state(hass: HomeAssistant, yaml_devices: str) -> None:
"""Test device tracker see records state correctly."""
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
await hass.async_block_till_done()