forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow teaching logbook about events (home-assistant#32444)
* Allow teaching logbook about events * Use async_add_executor_job * Fix tests
- Loading branch information
Showing
10 changed files
with
175 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Tests for alexa.""" | ||
from homeassistant.components import logbook | ||
from homeassistant.components.alexa.const import EVENT_ALEXA_SMART_HOME | ||
import homeassistant.core as ha | ||
from homeassistant.setup import async_setup_component | ||
|
||
|
||
async def test_humanify_alexa_event(hass): | ||
"""Test humanifying Alexa event.""" | ||
await async_setup_component(hass, "alexa", {}) | ||
hass.states.async_set("light.kitchen", "on", {"friendly_name": "Kitchen Light"}) | ||
|
||
results = list( | ||
logbook.humanify( | ||
hass, | ||
[ | ||
ha.Event( | ||
EVENT_ALEXA_SMART_HOME, | ||
{"request": {"namespace": "Alexa.Discovery", "name": "Discover"}}, | ||
), | ||
ha.Event( | ||
EVENT_ALEXA_SMART_HOME, | ||
{ | ||
"request": { | ||
"namespace": "Alexa.PowerController", | ||
"name": "TurnOn", | ||
"entity_id": "light.kitchen", | ||
} | ||
}, | ||
), | ||
ha.Event( | ||
EVENT_ALEXA_SMART_HOME, | ||
{ | ||
"request": { | ||
"namespace": "Alexa.PowerController", | ||
"name": "TurnOn", | ||
"entity_id": "light.non_existing", | ||
} | ||
}, | ||
), | ||
], | ||
) | ||
) | ||
|
||
event1, event2, event3 = results | ||
|
||
assert event1["name"] == "Amazon Alexa" | ||
assert event1["message"] == "send command Alexa.Discovery/Discover" | ||
assert event1["entity_id"] is None | ||
|
||
assert event2["name"] == "Amazon Alexa" | ||
assert ( | ||
event2["message"] | ||
== "send command Alexa.PowerController/TurnOn for Kitchen Light" | ||
) | ||
assert event2["entity_id"] == "light.kitchen" | ||
|
||
assert event3["name"] == "Amazon Alexa" | ||
assert ( | ||
event3["message"] | ||
== "send command Alexa.PowerController/TurnOn for light.non_existing" | ||
) | ||
assert event3["entity_id"] == "light.non_existing" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.