diff --git a/tests/test_airconditioner_capabilities.py b/tests/test_airconditioner_capabilities.py index 92a0ca1..f9f1d3b 100644 --- a/tests/test_airconditioner_capabilities.py +++ b/tests/test_airconditioner_capabilities.py @@ -157,15 +157,21 @@ def test_climate_write_preserves_half_degree_temperature_steps(): The increment on /temperatures/vs/0 lives inside its items[] entry (the same shape every fixture in the corpus uses), not at the resource's top level -- a fabricated flat `{"/temperatures/vs/0": {"increment": ...}}` - resource would pass a step-reading bug like that silently.""" - climate_desc = next(e for e in airconditioner.CLIMATE.entities if isinstance(e, ClimateDesc)) - write = climate_desc.write_fn + resource would pass a step-reading bug like that silently. + + Calls _climate_write directly rather than through ClimateDesc.write_fn + (as test_climate_write_targets above does): WriteFn only declares the + (payload, rep) shape every other write_fn honors, so the type checker + rejects a call carrying the climate-only href/resources params through + that narrower alias -- same reason test_coordinator_send_command.py and + test_airconditioner_artik051_krac.py import the function directly too. + """ resources = _load_device("airconditioner_cac") - assert write(("temperature_ocf", 24.5), {}, None, resources) == ( + assert airconditioner._climate_write(("temperature_ocf", 24.5), {}, None, resources) == ( ["temperature", "desired", "0"], {"temperature": 24.5}, ) - assert write(("temperature", 24.5), {}, None, resources) == ( + assert airconditioner._climate_write(("temperature", 24.5), {}, None, resources) == ( ["temperatures", "vs", "0"], { "x.com.samsung.da.items": [ @@ -180,11 +186,9 @@ def test_climate_write_rounds_to_whole_degree_with_no_advertised_increment(): increment field on /temperatures/vs/0's item -- target_temperature_step (climate.py) defaults to 1.0 there, so the write path must match rather than pass the raw value through unrounded.""" - climate_desc = next(e for e in airconditioner.CLIMATE.entities if isinstance(e, ClimateDesc)) - write = climate_desc.write_fn resources = _load_device("airconditioner_artik051_krac_18k") assert airconditioner._temperature_step(resources) is None - assert write(("temperature", 23.6), {}, None, resources) == ( + assert airconditioner._climate_write(("temperature", 23.6), {}, None, resources) == ( ["temperatures", "vs", "0"], { "x.com.samsung.da.items": [ @@ -199,10 +203,8 @@ def test_climate_write_rejects_non_numeric_temperature(): build a body with `{"temperature": None}` -- coordinator.py's async_send_command logs and drops a write_fn result of None instead of POSTing it.""" - climate_desc = next(e for e in airconditioner.CLIMATE.entities if isinstance(e, ClimateDesc)) - write = climate_desc.write_fn - assert write(("temperature_ocf", "not-a-number"), {}) is None - assert write(("temperature", None), {}) is None + assert airconditioner._climate_write(("temperature_ocf", "not-a-number"), {}) is None + assert airconditioner._climate_write(("temperature", None), {}) is None def test_climate_consumed_hrefs_declared_as_coverage():