mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Improve TAI8570 ignore tests in onewire (#92113)
Improve TAI8570 tests in onewire
This commit is contained in:
parent
7215f6320e
commit
aac750a44f
@ -1,6 +1,7 @@
|
|||||||
"""Tests for 1-Wire sensors."""
|
"""Tests for 1-Wire sensors."""
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
import logging
|
||||||
from unittest.mock import MagicMock, _patch_dict, patch
|
from unittest.mock import MagicMock, _patch_dict, patch
|
||||||
|
|
||||||
from pyownet.protocol import OwnetError
|
from pyownet.protocol import OwnetError
|
||||||
@ -8,7 +9,7 @@ import pytest
|
|||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
@ -68,12 +69,12 @@ async def test_tai8570_sensors(
|
|||||||
owproxy: MagicMock,
|
owproxy: MagicMock,
|
||||||
device_id: str,
|
device_id: str,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""The DS2602 is often used without TAI8570.
|
"""The DS2602 is often used without TAI8570.
|
||||||
|
|
||||||
The sensors should be ignored.
|
The sensors should be ignored.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
mock_devices = deepcopy(MOCK_OWPROXY_DEVICES)
|
mock_devices = deepcopy(MOCK_OWPROXY_DEVICES)
|
||||||
mock_device = mock_devices[device_id]
|
mock_device = mock_devices[device_id]
|
||||||
mock_device[ATTR_INJECT_READS].append(OwnetError)
|
mock_device[ATTR_INJECT_READS].append(OwnetError)
|
||||||
@ -82,11 +83,12 @@ async def test_tai8570_sensors(
|
|||||||
with _patch_dict(MOCK_OWPROXY_DEVICES, mock_devices):
|
with _patch_dict(MOCK_OWPROXY_DEVICES, mock_devices):
|
||||||
setup_owproxy_mock_devices(owproxy, Platform.SENSOR, [device_id])
|
setup_owproxy_mock_devices(owproxy, Platform.SENSOR, [device_id])
|
||||||
|
|
||||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
with caplog.at_level(logging.DEBUG):
|
||||||
await hass.async_block_till_done()
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
expected_entities = mock_device[Platform.SENSOR]
|
assert entity_registry.entities.get("sensor.12_111111111111_temperature") is None
|
||||||
for expected_entity in expected_entities:
|
assert "unreachable sensor /12.111111111111/TAI8570/temperature" in caplog.text
|
||||||
entity_id = expected_entity[ATTR_ENTITY_ID]
|
|
||||||
registry_entry = entity_registry.entities.get(entity_id)
|
assert entity_registry.entities.get("sensor.12_111111111111_pressure") is None
|
||||||
assert registry_entry is None
|
assert "unreachable sensor /12.111111111111/TAI8570/pressure" in caplog.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user