mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-10-29 09:11:57 +00:00
fix(config): report computed fields as read-only on update (#1454)
PUT /v1/config/{path} answered "does not exist in model" when the
target was a computed field such as eos_device_instruction_entity_ids.
Raise an explicit read-only error instead, so API clients can tell
read-only fields from unknown ones.
Closes #913
This commit is contained in:
@@ -486,6 +486,18 @@ def test_set_nested_key(path, value, expected, exception, config_eos):
|
||||
f"Expected exception {exception}, but got {type(e)}: {e}"
|
||||
)
|
||||
|
||||
def test_set_nested_key_read_only_computed_field(config_eos):
|
||||
"""Setting a computed field is reported as read-only, not as missing."""
|
||||
path = "adapter/homeassistant/eos_device_instruction_entity_ids"
|
||||
with pytest.raises(TypeError, match="read-only computed field"):
|
||||
config_eos.set_nested_value(path, ["sensor.eos_battery1"])
|
||||
|
||||
|
||||
def test_set_nested_key_unknown_field_still_reports_missing(config_eos):
|
||||
"""A field that does not exist keeps the original 'does not exist' message."""
|
||||
with pytest.raises(TypeError, match="does not exist in model"):
|
||||
config_eos.set_nested_value("adapter/homeassistant/no_such_field", 1)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"path, expected_value, exception",
|
||||
|
||||
Reference in New Issue
Block a user