Cleanup onewire tests (#92117)

This commit is contained in:
epenet 2023-04-29 11:18:16 +02:00 committed by GitHub
parent 58c5d98958
commit 7dfbfd45ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 98 additions and 1013 deletions

View file

@ -8,15 +8,13 @@ from homeassistant.components.onewire.const import (
DOMAIN,
INPUT_ENTRY_CLEAR_OPTIONS,
INPUT_ENTRY_DEVICE_SELECTION,
MANUFACTURER_MAXIM,
)
from homeassistant.config_entries import SOURCE_USER, ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.config_validation import ensure_list
from .const import MOCK_OWPROXY_DEVICES
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
@ -26,16 +24,14 @@ async def filled_device_registry(
hass: HomeAssistant, config_entry: ConfigEntry, device_registry: dr.DeviceRegistry
) -> dr.DeviceRegistry:
"""Fill device registry with mock devices."""
for device_details in MOCK_OWPROXY_DEVICES.values():
if infos := device_details.get("device_info"):
for info in ensure_list(infos):
device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers=info["identifiers"],
manufacturer=info["manufacturer"],
model=info["model"],
name=info["name"],
)
for key in ("28.111111111111", "28.222222222222", "28.222222222223"):
device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, key)},
manufacturer=MANUFACTURER_MAXIM,
model="DS18B20",
name=key,
)
return device_registry