Fix ty type-check failures in new tests (CI)
My local ty runs only covered custom_components, not tests -- CI runs 'ty check custom_components tests', which this branch had been failing since the version-bump commit. All 13 diagnostics were the same two established idioms this test suite already uses elsewhere, just missing here: - desc.write_fn/options_field are SelectDesc-only fields, unresolved on the SamsungEntityDescription base a bare 'next(e for e in ... if e.key == ...)' infers -- needs 'and isinstance(e, SelectDesc)' in the filter, same as test_fridge_capabilities.py's existing selects. - rep_fn/match_fn are typed Optional even after narrowing to a concrete descriptor/capability, so calling one needs an explicit 'assert x.rep_fn is not None' first, same as test_common_capabilities.py's POWER_VS_FALLBACK.match_fn precedent. No behavior change -- test bodies are identical, just type-checkable.
This commit is contained in:
4 files changed
+14
-2
No files matched your search
@@ -784,6 +784,7 @@ def test_air_filter_usage_hours_derived_from_percent_and_capacity():
|
|||||||
for e in airconditioner.AIR_FILTER.entities
|
for e in airconditioner.AIR_FILTER.entities
|
||||||
if e.key == "air_filter_usage_hours" and isinstance(e, SensorDesc)
|
if e.key == "air_filter_usage_hours" and isinstance(e, SensorDesc)
|
||||||
)
|
)
|
||||||
|
assert desc.rep_fn is not None
|
||||||
assert (
|
assert (
|
||||||
desc.rep_fn(
|
desc.rep_fn(
|
||||||
{"x.com.samsung.da.filterUsage": "91", "x.com.samsung.da.filterCapacity": "500"}
|
{"x.com.samsung.da.filterUsage": "91", "x.com.samsung.da.filterCapacity": "500"}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from custom_components.localthings.registry.adapter import flatten
|
|||||||
from custom_components.localthings.registry.by_type import for_device_by_model
|
from custom_components.localthings.registry.by_type import for_device_by_model
|
||||||
from custom_components.localthings.registry.capabilities import fridge
|
from custom_components.localthings.registry.capabilities import fridge
|
||||||
from custom_components.localthings.registry.discovery import discover
|
from custom_components.localthings.registry.discovery import discover
|
||||||
|
from custom_components.localthings.registry.entities import SelectDesc
|
||||||
from tests.conftest import _load_device
|
from tests.conftest import _load_device
|
||||||
|
|
||||||
FIXTURE = "refrigerator_tp1x_ref_21k_autodoor"
|
FIXTURE = "refrigerator_tp1x_ref_21k_autodoor"
|
||||||
@@ -51,7 +52,11 @@ def test_auto_door_voice_control_reads_status_lock():
|
|||||||
|
|
||||||
|
|
||||||
def test_auto_door_timer_reads_its_own_options():
|
def test_auto_door_timer_reads_its_own_options():
|
||||||
desc = next(e for e in fridge.AUTO_DOOR_TIMER.entities if e.key == "auto_door_timer")
|
desc = next(
|
||||||
|
e
|
||||||
|
for e in fridge.AUTO_DOOR_TIMER.entities
|
||||||
|
if e.key == "auto_door_timer" and isinstance(e, SelectDesc)
|
||||||
|
)
|
||||||
rep = {
|
rep = {
|
||||||
"x.com.samsung.da.time.desired": "1",
|
"x.com.samsung.da.time.desired": "1",
|
||||||
"x.com.samsung.da.time.supportedOptions": ["1", "2", "3", "4", "5", "6"],
|
"x.com.samsung.da.time.supportedOptions": ["1", "2", "3", "4", "5", "6"],
|
||||||
@@ -70,5 +75,6 @@ def test_auto_door_single_variant_href_bound_with_no_entities():
|
|||||||
no paired current/desired field to expose, so it's coverage-only via
|
no paired current/desired field to expose, so it's coverage-only via
|
||||||
the shared AUTO_DOOR_VARIANT pattern cap, not an entry of its own."""
|
the shared AUTO_DOOR_VARIANT pattern cap, not an entry of its own."""
|
||||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||||
|
assert fridge.AUTO_DOOR_VARIANT.match_fn is not None
|
||||||
_reg, resources = _fridge()
|
_reg, resources = _fridge()
|
||||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/single/vs/0"], resources)
|
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/single/vs/0"], resources)
|
||||||
@@ -52,5 +52,6 @@ def test_auto_door_opener_present():
|
|||||||
|
|
||||||
def test_auto_door_kimchi_variant_href_bound_with_no_entities():
|
def test_auto_door_kimchi_variant_href_bound_with_no_entities():
|
||||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||||
|
assert fridge.AUTO_DOOR_VARIANT.match_fn is not None
|
||||||
_reg, resources = _fridge()
|
_reg, resources = _fridge()
|
||||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/kimchi/vs/0"], resources)
|
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/kimchi/vs/0"], resources)
|
||||||
@@ -10,6 +10,7 @@ from custom_components.localthings.registry.adapter import flatten
|
|||||||
from custom_components.localthings.registry.by_type import for_device_by_oic_type, resolve
|
from custom_components.localthings.registry.by_type import for_device_by_oic_type, resolve
|
||||||
from custom_components.localthings.registry.capabilities import fridge
|
from custom_components.localthings.registry.capabilities import fridge
|
||||||
from custom_components.localthings.registry.discovery import discover
|
from custom_components.localthings.registry.discovery import discover
|
||||||
|
from custom_components.localthings.registry.entities import SelectDesc
|
||||||
from tests.conftest import _load_device
|
from tests.conftest import _load_device
|
||||||
|
|
||||||
FIXTURE = "refrigerator_winecellar"
|
FIXTURE = "refrigerator_winecellar"
|
||||||
@@ -67,7 +68,9 @@ def test_deodor_filter_has_its_own_keys_not_air_filters():
|
|||||||
|
|
||||||
def test_winecellar_pantry_zone_mode_options_and_write():
|
def test_winecellar_pantry_zone_mode_options_and_write():
|
||||||
desc = next(
|
desc = next(
|
||||||
e for e in fridge.WINECELLAR_PANTRY_ZONE.entities if e.key == "winecellar_pantry_zone_mode"
|
e
|
||||||
|
for e in fridge.WINECELLAR_PANTRY_ZONE.entities
|
||||||
|
if e.key == "winecellar_pantry_zone_mode" and isinstance(e, SelectDesc)
|
||||||
)
|
)
|
||||||
assert desc.options_field == "x.com.samsung.da.supportedOptions"
|
assert desc.options_field == "x.com.samsung.da.supportedOptions"
|
||||||
assert desc.write_fn is not None
|
assert desc.write_fn is not None
|
||||||
@@ -82,5 +85,6 @@ def test_winecellar_pantry_zone_mode_options_and_write():
|
|||||||
def test_winecellar_variant_and_info_hrefs_bound_with_no_entities():
|
def test_winecellar_variant_and_info_hrefs_bound_with_no_entities():
|
||||||
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
assert fridge.AUTO_DOOR_VARIANT.entities == ()
|
||||||
assert fridge.WINECELLAR_INFO.entities == ()
|
assert fridge.WINECELLAR_INFO.entities == ()
|
||||||
|
assert fridge.AUTO_DOOR_VARIANT.match_fn is not None
|
||||||
_reg, resources = _fridge()
|
_reg, resources = _fridge()
|
||||||
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/winecellar/vs/0"], resources)
|
assert fridge.AUTO_DOOR_VARIANT.match_fn(resources["/autodoor/winecellar/vs/0"], resources)
|
||||||
Reference in new issue
Block a user