UX-15: mutations fail named checks, not crashes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -339,10 +339,14 @@ class Session:
|
||||
|
||||
|
||||
def _refused(coro):
|
||||
"""True only for the read-only refusal; a request that reached the
|
||||
session (AssertionError there) or no refusal at all is False."""
|
||||
try:
|
||||
asyncio.run(coro)
|
||||
except H.ReadOnly:
|
||||
return True
|
||||
except Exception: # noqa: BLE001
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
@@ -372,8 +376,10 @@ check("control: a normal HomeAssistant does send the write", _sent
|
||||
try:
|
||||
M.Controller(dict(_ok), _ro, None, None, stop=asyncio.Event())
|
||||
_built = True
|
||||
except ValueError:
|
||||
_built = False
|
||||
except ValueError as err:
|
||||
_built = "read-only" not in str(err)
|
||||
except Exception: # noqa: BLE001
|
||||
_built = True # it got past the check and failed on something else
|
||||
check("no controller can be built on a read-only HomeAssistant", not _built)
|
||||
try:
|
||||
setuponly.SetupOnly(SHIPPED, _rw, None)
|
||||
|
||||
Reference in New Issue
Block a user