test(intents): the button's uninstalled-app press, with the device's own words (t17)
Acceptance item 3 named this case explicitly: a registered intent whose app is
gone must fail the press HONESTLY. The device's sentence is what the error
carries ('does not exist', naming the component), the press is attempted exactly
once, and it raises rather than doing nothing.
This commit is contained in:
1 parent
e6c6bdb1e6
commit
66846b2f82
1 file changed
+32
@@ -1044,6 +1044,38 @@ class TestTheButtons:
|
|||||||
modules.media.intent_am_start_command(intent, {"id": "7"})
|
modules.media.intent_am_start_command(intent, {"id": "7"})
|
||||||
]
|
]
|
||||||
|
|
||||||
|
async def test_an_uninstalled_app_fails_the_press_honestly(self, modules):
|
||||||
|
"""The plan's acceptance: a package that is gone must not press silently.
|
||||||
|
|
||||||
|
The device is the authority here — its own sentence is what the error
|
||||||
|
carries, so the user learns WHICH component vanished instead of seeing a
|
||||||
|
button that did nothing.
|
||||||
|
"""
|
||||||
|
import homeassistant.exceptions as ha_exceptions
|
||||||
|
|
||||||
|
intent = {
|
||||||
|
**NETFLIX_INTENT,
|
||||||
|
"fields": [{"key": "id", "type": "string", "default": "7"}],
|
||||||
|
}
|
||||||
|
entry, added = await self._setup(
|
||||||
|
modules, {CONF_REGISTERED_INTENTS: [intent]}
|
||||||
|
)
|
||||||
|
poller = _RecordingPoller(
|
||||||
|
"Starting: Intent { act=android.intent.action.VIEW }\n"
|
||||||
|
"Error: Activity class {com.netflix.ninja/.MainActivity} does not exist."
|
||||||
|
)
|
||||||
|
entry.runtime_data = _manager(poller)
|
||||||
|
added[0]._manager = _manager(poller)
|
||||||
|
added[0].entity_id = "button.shield_netflix_open_a_title"
|
||||||
|
|
||||||
|
with pytest.raises(ha_exceptions.ServiceValidationError) as caught:
|
||||||
|
await added[0].async_press()
|
||||||
|
|
||||||
|
assert caught.value.translation_key == "intent_failed"
|
||||||
|
assert "does not exist" in str(caught.value)
|
||||||
|
assert "com.netflix.ninja/.MainActivity" in str(caught.value)
|
||||||
|
assert len(poller.commands) == 1, "attempted once, never retried"
|
||||||
|
|
||||||
async def test_a_button_with_no_manager_fails_loudly(self, modules):
|
async def test_a_button_with_no_manager_fails_loudly(self, modules):
|
||||||
"""A press that cannot reach the Shield RAISES — it never no-ops.
|
"""A press that cannot reach the Shield RAISES — it never no-ops.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user