mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Improve type hints in device_tracker tests (#120390)
This commit is contained in:
parent
7f20c1a489
commit
f8d5c9144a
@ -43,7 +43,7 @@ def calls(hass: HomeAssistant) -> list[ServiceCall]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def setup_zone(hass):
|
def setup_zone(hass: HomeAssistant) -> None:
|
||||||
"""Create test zone."""
|
"""Create test zone."""
|
||||||
hass.loop.run_until_complete(
|
hass.loop.run_until_complete(
|
||||||
async_setup_component(
|
async_setup_component(
|
||||||
|
@ -8,6 +8,7 @@ from types import ModuleType
|
|||||||
from unittest.mock import call, patch
|
from unittest.mock import call, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from typing_extensions import Generator
|
||||||
|
|
||||||
from homeassistant.components import device_tracker, zone
|
from homeassistant.components import device_tracker, zone
|
||||||
from homeassistant.components.device_tracker import SourceType, const, legacy
|
from homeassistant.components.device_tracker import SourceType, const, legacy
|
||||||
@ -49,7 +50,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="yaml_devices")
|
@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."""
|
"""Get a path for storing yaml devices."""
|
||||||
yaml_devices = hass.config.path(legacy.YAML_DEVICES)
|
yaml_devices = hass.config.path(legacy.YAML_DEVICES)
|
||||||
if os.path.isfile(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"
|
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."""
|
"""Test the rendering of the YAML configuration."""
|
||||||
dev_id = "test"
|
dev_id = "test"
|
||||||
device = legacy.Device(
|
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"
|
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."""
|
"""Test with no YAML file."""
|
||||||
with assert_setup_component(1, device_tracker.DOMAIN):
|
with assert_setup_component(1, device_tracker.DOMAIN):
|
||||||
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
||||||
@ -487,7 +488,7 @@ async def test_invalid_dev_id(
|
|||||||
assert not devices
|
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."""
|
"""Test device tracker see records state correctly."""
|
||||||
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user