Catch samsungtv websocket exceptions (#28849)

* catch websocket exceptions

* fix syntax

* use exceptions from base class

* add comments

* add test
This commit is contained in:
escoand authored and cgtobi committed 2019-11-25 10:45:50 +01:00
1 parent 5b64052d69
commit 430f7bdfd4
2 files changed
+21 -5

No files matched your search

@@ -8,6 +8,7 @@ from asynctest import mock
import pytest
from samsungctl import exceptions
from tests.common import async_fire_time_changed
from websocket import WebSocketException
from homeassistant.components.media_player import DEVICE_CLASS_TV
from homeassistant.components.media_player.const import (
@@ -387,6 +388,17 @@ async def test_send_key_unhandled_response(hass, remote):
assert state.state == STATE_ON
async def test_send_key_websocketexception(hass, remote):
"""Testing unhandled response exception."""
await setup_samsungtv(hass, MOCK_CONFIG)
remote.control = mock.Mock(side_effect=WebSocketException("Boom"))
assert await hass.services.async_call(
DOMAIN, SERVICE_VOLUME_UP, {ATTR_ENTITY_ID: ENTITY_ID}, True
)
state = hass.states.get(ENTITY_ID)
assert state.state == STATE_ON
async def test_send_key_os_error(hass, remote):
"""Testing broken pipe Exception."""
await setup_samsungtv(hass, MOCK_CONFIG)