refactor: replace exact-href door/temp/icemaker caps with generic pattern caps
Delete dead: DOOR_FRIDGE, DOOR_FREEZER, TEMP_FRIDGE/FREEZER_CURRENT/SETPOINT, ICEMAKER_ONE, ICEMAKER_TWO, ICE2_MODES, temperature bounds constants. Add: TEMP_CURRENT_GENERIC (href_prefix=/temperature/current/), TEMP_SETPOINT_GENERIC (href_prefix=/temperature/desired/, write derives CoAP path from href), ICEMAKER_GENERIC (href_prefix=/icemaker/, match_fn gates on iceMaker.state field). Key derivation strips 'vs' segments alongside digits so icemaker hrefs like /icemaker/one/vs/0 produce icemaker_one_state not icemaker_one_vs_state. write_fn signature extended: adapter now passes href as 3rd positional arg; all existing write_fns updated to accept href=None. Fridge golden: old ice1_*/ice2_*/fridge_*/freezer_* keys replaced by icemaker_one_*/icemaker_two_*/temperature_current_*/temperature_desired_*.
This commit is contained in:
1 parent
9e5a169c82
commit
785154eb83
10 files changed
+116
-189
No files matched your search
@@ -25,12 +25,11 @@ def test_two_iceMakers_get_distinct_keys():
|
||||
resources = _load_resources('10.0.0.254')
|
||||
reg = refrigerator.REGISTRY
|
||||
bound = discover(resources, reg.capabilities, reg.pattern_capabilities)
|
||||
ice_keys = sorted(f"{b.desc.key}{b.instance}" for b in bound
|
||||
if b.desc.key.startswith('ice'))
|
||||
# ice1_* and ice2_* are distinct
|
||||
ice1_keys = [k for k in ice_keys if k.startswith('ice1')]
|
||||
ice2_keys = [k for k in ice_keys if k.startswith('ice2')]
|
||||
assert ice1_keys, "No ice1_* keys found"
|
||||
assert ice2_keys, "No ice2_* keys found"
|
||||
assert set(ice1_keys).isdisjoint(set(ice2_keys)), \
|
||||
f"ice1 and ice2 keys overlap: {ice1_keys} vs {ice2_keys}"
|
||||
ice_keys = sorted(_key(b) for b in bound if _key(b).startswith('icemaker_'))
|
||||
# icemaker_one_* and icemaker_two_* are distinct
|
||||
ice_one_keys = [k for k in ice_keys if k.startswith('icemaker_one_')]
|
||||
ice_two_keys = [k for k in ice_keys if k.startswith('icemaker_two_')]
|
||||
assert ice_one_keys, "No icemaker_one_* keys found"
|
||||
assert ice_two_keys, "No icemaker_two_* keys found"
|
||||
assert set(ice_one_keys).isdisjoint(set(ice_two_keys)), \
|
||||
f"icemaker_one and icemaker_two keys overlap: {ice_one_keys} vs {ice_two_keys}"
|
||||
Reference in new issue
Block a user