De-duplicate the legacy ARTIK051 AC board-generation test (#161)
capabilities/airconditioner.py's is_legacy_board() (renamed from the private _is_legacy_board -- it's now a cross-module helper) and climate.py's _legacy_airflow() implemented the same "does this board have /airflow/vs/0 but no /wind/strength/vs/0" test independently, one via literal href strings and the other via coordinator.resource() truthiness. is_legacy_board() now uses the module's own HREF_AIRFLOW/HREF_WIND_STRENGTH constants, and _legacy_airflow() delegates to it via a minimal two-key presence dict (cheaper than a full last_resources snapshot copy) instead of re-implementing the check, so the token entities and the climate card's legacy read/write paths can't drift apart on which board generation is in play.
This commit is contained in:
@@ -24,7 +24,8 @@ from custom_components.localthings.registry.by_type import (
|
||||
airconditioner, for_device_by_model,
|
||||
)
|
||||
from custom_components.localthings.registry.capabilities.airconditioner import (
|
||||
HREF_AIRFLOW, _option_number_write, _option_switch_write,
|
||||
HREF_AIRFLOW, HREF_WIND_STRENGTH, _option_number_write,
|
||||
_option_switch_write, is_legacy_board,
|
||||
)
|
||||
from custom_components.localthings.registry.discovery import discover
|
||||
from custom_components.localthings.registry.entities import ClimateDesc
|
||||
@@ -119,6 +120,22 @@ def test_token_entities_stay_off_newer_boards():
|
||||
assert key not in state, key
|
||||
|
||||
|
||||
def test_climate_legacy_airflow_gate_agrees_with_is_legacy_board():
|
||||
"""issue #161: climate.py's _legacy_airflow() delegates to
|
||||
capabilities/airconditioner.py's is_legacy_board() instead of
|
||||
re-implementing the same presence/absence check, so the token entities
|
||||
and the climate card's legacy read/write paths can't drift apart on
|
||||
which board generation is in play."""
|
||||
legacy_resources = _load_device(FIXTURE)
|
||||
assert is_legacy_board(legacy_resources) is True
|
||||
assert _climate(legacy_resources)._legacy_airflow() == legacy_resources[HREF_AIRFLOW]
|
||||
|
||||
newer_resources = _load_device('airconditioner_tp1x_rac')
|
||||
assert is_legacy_board(newer_resources) is False
|
||||
assert _climate(newer_resources)._legacy_airflow() == {}
|
||||
assert HREF_WIND_STRENGTH in newer_resources
|
||||
|
||||
|
||||
def test_absent_token_yields_no_entity():
|
||||
"""The issue #136 unit of this same model reports no Spi token."""
|
||||
resources = _load_device(FIXTURE)
|
||||
|
||||
Reference in New Issue
Block a user