init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1 @@
"""Tests for the Bryant Evolution integration."""

View File

@@ -0,0 +1,70 @@
"""Common fixtures for the Bryant Evolution tests."""
from collections.abc import Generator, Mapping
from unittest.mock import AsyncMock, patch
from evolutionhttp import BryantEvolutionLocalClient
import pytest
from homeassistant.components.bryant_evolution.const import CONF_SYSTEM_ZONE, DOMAIN
from homeassistant.const import CONF_FILENAME
from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from tests.common import MockConfigEntry
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.bryant_evolution.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
DEFAULT_SYSTEM_ZONES = ((1, 1), (1, 2), (2, 3))
"""
A tuple of (system, zone) pairs representing the default system and zone configurations
for the Bryant Evolution integration.
"""
@pytest.fixture(autouse=True)
def mock_evolution_client_factory() -> Generator[AsyncMock]:
"""Mock an Evolution client."""
with patch(
"evolutionhttp.BryantEvolutionLocalClient.get_client",
austospec=True,
) as mock_get_client:
clients: Mapping[tuple[int, int], AsyncMock] = {}
for system, zone in DEFAULT_SYSTEM_ZONES:
clients[(system, zone)] = AsyncMock(spec=BryantEvolutionLocalClient)
client = clients[system, zone]
client.read_zone_name.return_value = f"System {system} Zone {zone}"
client.read_current_temperature.return_value = 75
client.read_hvac_mode.return_value = ("COOL", False)
client.read_fan_mode.return_value = "AUTO"
client.read_cooling_setpoint.return_value = 72
mock_get_client.side_effect = lambda system, zone, tty: clients[
(system, zone)
]
yield mock_get_client
@pytest.fixture
async def mock_evolution_entry(
hass: HomeAssistant,
mock_evolution_client_factory: AsyncMock,
) -> MockConfigEntry:
"""Configure and return a Bryant evolution integration."""
hass.config.units = US_CUSTOMARY_SYSTEM
entry = MockConfigEntry(
entry_id="01J3XJZSTEF6G5V0QJX6HBC94T", # For determinism in snapshot tests
domain=DOMAIN,
data={CONF_FILENAME: "/dev/ttyUSB0", CONF_SYSTEM_ZONE: [(1, 1)]},
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
return entry

View File

@@ -0,0 +1,83 @@
# serializer version: 1
# name: test_setup_integration_success[climate.system_1_zone_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'fan_modes': list([
'auto',
'low',
'med',
'high',
]),
'hvac_modes': list([
<HVACMode.HEAT: 'heat'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 95,
'min_temp': 45,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.system_1_zone_1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': None,
'platform': 'bryant_evolution',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 395>,
'translation_key': None,
'unique_id': '01J3XJZSTEF6G5V0QJX6HBC94T-S1-Z1',
'unit_of_measurement': None,
})
# ---
# name: test_setup_integration_success[climate.system_1_zone_1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 75,
'fan_mode': 'auto',
'fan_modes': list([
'auto',
'low',
'med',
'high',
]),
'friendly_name': 'System 1 Zone 1',
'hvac_action': <HVACAction.OFF: 'off'>,
'hvac_modes': list([
<HVACMode.HEAT: 'heat'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 95,
'min_temp': 45,
'supported_features': <ClimateEntityFeature: 395>,
'target_temp_high': None,
'target_temp_low': None,
'temperature': 72,
}),
'context': <ANY>,
'entity_id': 'climate.system_1_zone_1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'cool',
})
# ---

View File

@@ -0,0 +1,259 @@
"""Test the BryantEvolutionClient type."""
from collections.abc import Generator
from datetime import timedelta
import logging
from unittest.mock import AsyncMock
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.bryant_evolution.climate import SCAN_INTERVAL
from homeassistant.components.climate import (
ATTR_FAN_MODE,
ATTR_HVAC_ACTION,
ATTR_HVAC_MODE,
ATTR_TEMPERATURE,
DOMAIN as CLIMATE_DOMAIN,
SERVICE_SET_FAN_MODE,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_TEMPERATURE,
HVACAction,
)
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
_LOGGER = logging.getLogger(__name__)
async def trigger_polling(hass: HomeAssistant, freezer: FrozenDateTimeFactory) -> None:
"""Trigger a polling event."""
freezer.tick(SCAN_INTERVAL + timedelta(seconds=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()
async def test_setup_integration_success(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
mock_evolution_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
) -> None:
"""Test that an instance can be constructed."""
await snapshot_platform(
hass, entity_registry, snapshot, mock_evolution_entry.entry_id
)
async def test_set_temperature_mode_cool(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
freezer: FrozenDateTimeFactory,
) -> None:
"""Test setting the temperature in cool mode."""
# Start with known initial conditions
client = await mock_evolution_client_factory(1, 1, "/dev/unused")
client.read_hvac_mode.return_value = ("COOL", False)
client.read_cooling_setpoint.return_value = 75
await trigger_polling(hass, freezer)
state = hass.states.get("climate.system_1_zone_1")
assert state.attributes["temperature"] == 75, state.attributes
# Make the call, modifting the mock client to throw an exception on
# read to ensure that the update is visible iff we call
# async_update_ha_state.
data = {ATTR_TEMPERATURE: 70}
data[ATTR_ENTITY_ID] = "climate.system_1_zone_1"
client.read_cooling_setpoint.side_effect = Exception("fake failure")
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, data, blocking=True
)
# Verify effect.
client.set_cooling_setpoint.assert_called_once_with(70)
state = hass.states.get("climate.system_1_zone_1")
assert state.attributes["temperature"] == 70
async def test_set_temperature_mode_heat(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
freezer: FrozenDateTimeFactory,
) -> None:
"""Test setting the temperature in heat mode."""
# Start with known initial conditions
client = await mock_evolution_client_factory(1, 1, "/dev/unused")
client.read_hvac_mode.return_value = ("HEAT", False)
client.read_heating_setpoint.return_value = 60
await trigger_polling(hass, freezer)
# Make the call, modifting the mock client to throw an exception on
# read to ensure that the update is visible iff we call
# async_update_ha_state.
data = {"temperature": 65}
data[ATTR_ENTITY_ID] = "climate.system_1_zone_1"
client.read_heating_setpoint.side_effect = Exception("fake failure")
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, data, blocking=True
)
# Verify effect.
state = hass.states.get("climate.system_1_zone_1")
assert state.attributes["temperature"] == 65, state.attributes
async def test_set_temperature_mode_heat_cool(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
freezer: FrozenDateTimeFactory,
) -> None:
"""Test setting the temperature in heat_cool mode."""
# Enter heat_cool with known setpoints
mock_client = await mock_evolution_client_factory(1, 1, "/dev/unused")
mock_client.read_hvac_mode.return_value = ("AUTO", False)
mock_client.read_cooling_setpoint.return_value = 90
mock_client.read_heating_setpoint.return_value = 40
await trigger_polling(hass, freezer)
state = hass.states.get("climate.system_1_zone_1")
assert state.state == "heat_cool"
assert state.attributes["target_temp_low"] == 40
assert state.attributes["target_temp_high"] == 90
# Make the call, modifting the mock client to throw an exception on
# read to ensure that the update is visible iff we call
# async_update_ha_state.
mock_client.read_heating_setpoint.side_effect = Exception("fake failure")
mock_client.read_cooling_setpoint.side_effect = Exception("fake failure")
data = {"target_temp_low": 70, "target_temp_high": 80}
data[ATTR_ENTITY_ID] = "climate.system_1_zone_1"
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_SET_TEMPERATURE, data, blocking=True
)
state = hass.states.get("climate.system_1_zone_1")
assert state.attributes["target_temp_low"] == 70, state.attributes
assert state.attributes["target_temp_high"] == 80, state.attributes
mock_client.set_cooling_setpoint.assert_called_once_with(80)
mock_client.set_heating_setpoint.assert_called_once_with(70)
async def test_set_fan_mode(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
) -> None:
"""Test that setting fan mode works."""
mock_client = await mock_evolution_client_factory(1, 1, "/dev/unused")
fan_modes = ["auto", "low", "med", "high"]
for mode in fan_modes:
# Make the call, modifting the mock client to throw an exception on
# read to ensure that the update is visible iff we call
# async_update_ha_state.
mock_client.read_fan_mode.side_effect = Exception("fake failure")
data = {ATTR_FAN_MODE: mode}
data[ATTR_ENTITY_ID] = "climate.system_1_zone_1"
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_SET_FAN_MODE, data, blocking=True
)
assert (
hass.states.get("climate.system_1_zone_1").attributes[ATTR_FAN_MODE] == mode
)
mock_client.set_fan_mode.assert_called_with(mode)
@pytest.mark.parametrize(
("hvac_mode", "evolution_mode"),
[("heat_cool", "auto"), ("heat", "heat"), ("cool", "cool"), ("off", "off")],
)
async def test_set_hvac_mode(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
hvac_mode,
evolution_mode,
) -> None:
"""Test that setting HVAC mode works."""
mock_client = await mock_evolution_client_factory(1, 1, "/dev/unused")
# Make the call, modifting the mock client to throw an exception on
# read to ensure that the update is visible iff we call
# async_update_ha_state.
data = {ATTR_HVAC_MODE: hvac_mode}
data[ATTR_ENTITY_ID] = "climate.system_1_zone_1"
mock_client.read_hvac_mode.side_effect = Exception("fake failure")
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_SET_HVAC_MODE, data, blocking=True
)
await hass.async_block_till_done()
assert hass.states.get("climate.system_1_zone_1").state == evolution_mode
mock_client.set_hvac_mode.assert_called_with(evolution_mode)
@pytest.mark.parametrize(
("curr_temp", "expected_action"),
[(62, HVACAction.HEATING), (70, HVACAction.OFF), (80, HVACAction.COOLING)],
)
async def test_read_hvac_action_heat_cool(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
freezer: FrozenDateTimeFactory,
curr_temp: int,
expected_action: HVACAction,
) -> None:
"""Test that we can read the current HVAC action in heat_cool mode."""
htsp = 68
clsp = 72
mock_client = await mock_evolution_client_factory(1, 1, "/dev/unused")
mock_client.read_heating_setpoint.return_value = htsp
mock_client.read_cooling_setpoint.return_value = clsp
is_active = curr_temp < htsp or curr_temp > clsp
mock_client.read_hvac_mode.return_value = ("auto", is_active)
mock_client.read_current_temperature.return_value = curr_temp
await trigger_polling(hass, freezer)
state = hass.states.get("climate.system_1_zone_1")
assert state.attributes[ATTR_HVAC_ACTION] == expected_action
@pytest.mark.parametrize(
("mode", "active", "expected_action"),
[
("heat", True, "heating"),
("heat", False, "off"),
("cool", True, "cooling"),
("cool", False, "off"),
("off", False, "off"),
],
)
async def test_read_hvac_action(
hass: HomeAssistant,
mock_evolution_entry: MockConfigEntry,
mock_evolution_client_factory: Generator[AsyncMock],
freezer: FrozenDateTimeFactory,
mode: str,
active: bool,
expected_action: str,
) -> None:
"""Test that we can read the current HVAC action."""
# Initial state should be no action.
assert (
hass.states.get("climate.system_1_zone_1").attributes[ATTR_HVAC_ACTION]
== HVACAction.OFF
)
# Perturb the system and verify we see an action.
mock_client = await mock_evolution_client_factory(1, 1, "/dev/unused")
mock_client.read_heating_setpoint.return_value = 75 # Needed if mode == heat
mock_client.read_hvac_mode.return_value = (mode, active)
await trigger_polling(hass, freezer)
assert (
hass.states.get("climate.system_1_zone_1").attributes[ATTR_HVAC_ACTION]
== expected_action
)

View File

@@ -0,0 +1,164 @@
"""Test the Bryant Evolution config flow."""
from unittest.mock import DEFAULT, AsyncMock, patch
from evolutionhttp import BryantEvolutionLocalClient, ZoneInfo
from homeassistant import config_entries
from homeassistant.components.bryant_evolution.const import CONF_SYSTEM_ZONE, DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_FILENAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
async def test_form_success(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with (
patch.object(
BryantEvolutionLocalClient,
"enumerate_zones",
return_value=DEFAULT,
) as mock_call,
):
mock_call.side_effect = lambda system_id, filename: {
1: [ZoneInfo(1, 1, "S1Z1"), ZoneInfo(1, 2, "S1Z2")],
2: [ZoneInfo(2, 3, "S2Z2"), ZoneInfo(2, 4, "S2Z3")],
}.get(system_id, [])
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_FILENAME: "test_form_success",
},
)
assert result["type"] is FlowResultType.CREATE_ENTRY, result
assert result["title"] == "SAM at test_form_success"
assert result["data"] == {
CONF_FILENAME: "test_form_success",
CONF_SYSTEM_ZONE: [(1, 1), (1, 2), (2, 3), (2, 4)],
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_cannot_connect(
hass: HomeAssistant,
mock_evolution_client_factory: AsyncMock,
mock_setup_entry: AsyncMock,
) -> None:
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
with (
patch.object(
BryantEvolutionLocalClient,
"enumerate_zones",
return_value=DEFAULT,
) as mock_call,
):
mock_call.return_value = []
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_FILENAME: "test_form_cannot_connect",
},
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
with (
patch.object(
BryantEvolutionLocalClient,
"enumerate_zones",
return_value=DEFAULT,
) as mock_call,
):
mock_call.side_effect = lambda system_id, filename: {
1: [ZoneInfo(1, 1, "S1Z1"), ZoneInfo(1, 2, "S1Z2")],
2: [ZoneInfo(2, 3, "S2Z3"), ZoneInfo(2, 4, "S2Z4")],
}.get(system_id, [])
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_FILENAME: "some-serial",
},
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "SAM at some-serial"
assert result["data"] == {
CONF_FILENAME: "some-serial",
CONF_SYSTEM_ZONE: [(1, 1), (1, 2), (2, 3), (2, 4)],
}
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_cannot_connect_bad_file(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_evolution_client_factory: AsyncMock,
) -> None:
"""Test we handle cannot connect error from a missing file."""
mock_evolution_client_factory.side_effect = FileNotFoundError("test error")
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
# This file does not exist.
CONF_FILENAME: "test_form_cannot_connect_bad_file",
},
)
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
async def test_reconfigure(
hass: HomeAssistant,
mock_setup_entry: AsyncMock,
mock_evolution_entry: MockConfigEntry,
) -> None:
"""Test that reconfigure discovers additional systems and zones."""
# Reconfigure with additional systems and zones.
result = await mock_evolution_entry.start_reconfigure_flow(hass)
with (
patch.object(
BryantEvolutionLocalClient,
"enumerate_zones",
return_value=DEFAULT,
) as mock_call,
):
mock_call.side_effect = lambda system_id, filename: {
1: [ZoneInfo(1, 1, "S1Z1")],
2: [ZoneInfo(2, 3, "S2Z3"), ZoneInfo(2, 4, "S2Z4"), ZoneInfo(2, 5, "S2Z5")],
}.get(system_id, [])
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_FILENAME: "test_reconfigure",
},
)
await hass.async_block_till_done()
assert result["type"] is FlowResultType.ABORT, result
assert result["reason"] == "reconfigure_successful"
config_entry = hass.config_entries.async_entries()[0]
assert config_entry.data[CONF_SYSTEM_ZONE] == [
(1, 1),
(2, 3),
(2, 4),
(2, 5),
]

View File

@@ -0,0 +1,112 @@
"""Test setup for the bryant_evolution integration."""
import logging
from unittest.mock import AsyncMock
from evolutionhttp import BryantEvolutionLocalClient
from freezegun.api import FrozenDateTimeFactory
from homeassistant.components.bryant_evolution.const import CONF_SYSTEM_ZONE, DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_FILENAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .conftest import DEFAULT_SYSTEM_ZONES
from .test_climate import trigger_polling
from tests.common import MockConfigEntry
_LOGGER = logging.getLogger(__name__)
async def test_setup_integration_prevented_by_unavailable_client(
hass: HomeAssistant, mock_evolution_client_factory: AsyncMock
) -> None:
"""Test that setup throws ConfigEntryNotReady when the client is unavailable."""
mock_evolution_client_factory.side_effect = FileNotFoundError("test error")
mock_evolution_entry = MockConfigEntry(
domain=DOMAIN,
data={
CONF_FILENAME: "test_setup_integration_prevented_by_unavailable_client",
CONF_SYSTEM_ZONE: [(1, 1)],
},
)
mock_evolution_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_evolution_entry.entry_id)
await hass.async_block_till_done()
assert mock_evolution_entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_integration_client_returns_none(
hass: HomeAssistant, mock_evolution_client_factory: AsyncMock
) -> None:
"""Test that an unavailable client causes ConfigEntryNotReady."""
mock_client = AsyncMock(spec=BryantEvolutionLocalClient)
mock_evolution_client_factory.side_effect = None
mock_evolution_client_factory.return_value = mock_client
mock_client.read_fan_mode.return_value = None
mock_client.read_current_temperature.return_value = None
mock_client.read_hvac_mode.return_value = None
mock_client.read_cooling_setpoint.return_value = None
mock_client.read_zone_name.return_value = None
mock_evolution_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_FILENAME: "/dev/ttyUSB0", CONF_SYSTEM_ZONE: [(1, 1)]},
)
mock_evolution_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_evolution_entry.entry_id)
await hass.async_block_till_done()
assert mock_evolution_entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_multiple_systems_zones(
hass: HomeAssistant,
mock_evolution_client_factory: AsyncMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Test that a device with multiple systems and zones works."""
hass.config.units = US_CUSTOMARY_SYSTEM
mock_evolution_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_FILENAME: "/dev/ttyUSB0", CONF_SYSTEM_ZONE: DEFAULT_SYSTEM_ZONES},
)
mock_evolution_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_evolution_entry.entry_id)
await hass.async_block_till_done()
# Set the temperature of each zone to its zone number so that we can
# ensure we've created the right client for each zone.
for sz, client in mock_evolution_entry.runtime_data.items():
client.read_current_temperature.return_value = sz[1]
await trigger_polling(hass, freezer)
# Check that each system and zone has the expected temperature value to
# verify that the initial setup flow worked as expected.
for sz in DEFAULT_SYSTEM_ZONES:
system = sz[0]
zone = sz[1]
state = hass.states.get(f"climate.system_{system}_zone_{zone}")
assert state, hass.states.async_all()
assert state.attributes["current_temperature"] == zone
# Check that the created devices are wired to each other as expected.
device_registry = dr.async_get(hass)
def find_device(name):
return next(filter(lambda x: x.name == name, device_registry.devices.values()))
sam = find_device("System Access Module")
s1 = find_device("System 1")
s2 = find_device("System 2")
s1z1 = find_device("System 1 Zone 1")
s1z2 = find_device("System 1 Zone 2")
s2z3 = find_device("System 2 Zone 3")
assert sam.via_device_id is None
assert s1.via_device_id == sam.id
assert s2.via_device_id == sam.id
assert s1z1.via_device_id == s1.id
assert s1z2.via_device_id == s1.id
assert s2z3.via_device_id == s2.id