Clean up microwave PR after main merge: dedupe skill doc, derive cook modes live
The merge from main had left the adding-device-support skill with a stale duplicate "Enum selects need translation support" section (referencing a nonexistent strings.json) sitting alongside the canonical version, and main's new "never hard-code the dump" guidance hadn't landed on this branch at all -- restore it and drop the duplicate. Apply that guidance to the microwave capability itself: MICROWAVE_MODE's cook_mode select was carrying a hardcoded _MICROWAVE_MODES tuple lifted from the single issue #66 dump, even though /mode/vs/0 reports its own live supportedModes list. Switch to options_field and validate writes against the live rep instead of the static vocabulary, so a microwave with a narrower or wider mode set (grill-less models, etc.) isn't stuck with this one unit's options. The microwave entities also shipped with no translations/en.json entries at all (cook_mode, cavity_state, power_level, cavity_temp) -- add them, mirrored into nl.json, and update the affected tests.
This commit is contained in:
5 files changed
+104
-37
No files matched your search
@@ -27,24 +27,38 @@ def test_microwave_fixture_resolves_and_has_no_unbound_hrefs():
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# MICROWAVE_MODE -- SelectDesc with non-empty options
|
||||
# MICROWAVE_MODE -- SelectDesc reads its options live from supportedModes
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_microwave_mode_options_nonempty():
|
||||
assert len(microwave.MICROWAVE_MODE.entities[0].options) > 0
|
||||
_SUPPORTED_MODES_REP = {'x.com.samsung.da.supportedModes': [
|
||||
'NoOperation', 'MicroWave', 'MicroWaveGrill', 'Grill', 'Autocook', 'AutocookCustom',
|
||||
]}
|
||||
|
||||
|
||||
def test_microwave_mode_options_field():
|
||||
desc = microwave.MICROWAVE_MODE.entities[0]
|
||||
assert desc.options_field == 'x.com.samsung.da.supportedModes'
|
||||
|
||||
|
||||
def test_microwave_mode_write_round_trips():
|
||||
desc = microwave.MICROWAVE_MODE.entities[0]
|
||||
valid_mode = desc.options[1] # e.g. 'MicroWave'
|
||||
path, body = desc.write_fn(valid_mode, {})
|
||||
path, body = desc.write_fn('MicroWave', _SUPPORTED_MODES_REP)
|
||||
assert path == ['mode', 'vs', '0']
|
||||
assert body['x.com.samsung.da.modes'] == [valid_mode]
|
||||
assert body['x.com.samsung.da.modes'] == ['MicroWave']
|
||||
|
||||
|
||||
def test_microwave_mode_rejects_unknown():
|
||||
desc = microwave.MICROWAVE_MODE.entities[0]
|
||||
assert desc.write_fn('SpaghettiMode', {}) is None
|
||||
assert desc.write_fn('SpaghettiMode', _SUPPORTED_MODES_REP) is None
|
||||
|
||||
|
||||
def test_microwave_mode_rejects_when_not_in_live_supported_list():
|
||||
"""A mode absent from *this* device's live supportedModes is rejected
|
||||
even if another microwave model supports it -- the write must not fall
|
||||
back to a static vocabulary."""
|
||||
desc = microwave.MICROWAVE_MODE.entities[0]
|
||||
narrower_rep = {'x.com.samsung.da.supportedModes': ['NoOperation', 'MicroWave']}
|
||||
assert desc.write_fn('Grill', narrower_rep) is None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user