Adjust ms.remote.control error logging in SamsungTV (#67988)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet
2022-03-12 12:20:04 +01:00
committed by GitHub
parent 0d8f649bd6
commit 23b8229143
3 changed files with 76 additions and 6 deletions

View File

@@ -1066,3 +1066,40 @@ async def test_select_source_app(hass: HomeAssistant, remotews: Mock) -> None:
assert len(commands) == 1
assert isinstance(commands[0], ChannelEmitCommand)
assert commands[0].params["data"]["appId"] == "3201608010191"
async def test_websocket_unsupported_remote_control(
hass: HomeAssistant, remotews: Mock, caplog: pytest.LogCaptureFixture
) -> None:
"""Test for turn_off."""
with patch(
"homeassistant.components.samsungtv.bridge.Remote",
side_effect=[OSError("Boom"), DEFAULT_MOCK],
):
await setup_samsungtv(hass, MOCK_CONFIGWS)
remotews.send_command.reset_mock()
assert await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
remotews.raise_mock_ws_event_callback(
"ms.error",
{
"event": "ms.error",
"data": {"message": "unrecognized method value : ms.remote.control"},
},
)
# key called
assert remotews.send_command.call_count == 1
commands = remotews.send_command.call_args_list[0].args[0]
assert len(commands) == 1
assert isinstance(commands[0], SendRemoteKey)
assert commands[0].params["DataOfCmd"] == "KEY_POWER"
# error logged
assert (
"Your TV seems to be unsupported by SamsungTVWSBridge and may need a PIN: "
"'unrecognized method value : ms.remote.control'" in caplog.text
)