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.
Apple TV: Use replacement commands for deprecated ones (home-assistan…
…t#102056) Co-authored-by: Robert Resch <robert@resch.dev>
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Test apple_tv remote.""" | ||
from unittest.mock import AsyncMock | ||
|
||
import pytest | ||
|
||
from homeassistant.components.apple_tv.remote import AppleTVRemote | ||
from homeassistant.components.remote import ATTR_DELAY_SECS, ATTR_NUM_REPEATS | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("command", "method"), | ||
[ | ||
("up", "remote_control.up"), | ||
("wakeup", "power.turn_on"), | ||
("volume_up", "audio.volume_up"), | ||
("home_hold", "remote_control.home"), | ||
], | ||
ids=["up", "wakeup", "volume_up", "home_hold"], | ||
) | ||
async def test_send_command(command: str, method: str) -> None: | ||
"""Test "send_command" method.""" | ||
remote = AppleTVRemote("test", "test", None) | ||
remote.atv = AsyncMock() | ||
await remote.async_send_command( | ||
[command], **{ATTR_NUM_REPEATS: 1, ATTR_DELAY_SECS: 0} | ||
) | ||
assert len(remote.atv.method_calls) == 1 | ||
assert str(remote.atv.method_calls[0]) == f"call.{method}()" |