Fix webostv notify service (#66760)

pull/66352/head^2
Shay Levy 2022-02-17 21:13:09 +02:00 committed by GitHub
parent 750b48dcaf
commit e79348f952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -46,8 +46,8 @@ class LgWebOSNotificationService(BaseNotificationService):
if not self._client.is_connected():
await self._client.connect()
data = kwargs.get(ATTR_DATA)
icon_path = data.get(CONF_ICON, "") if data else None
data = kwargs.get(ATTR_DATA, {})
icon_path = data.get(CONF_ICON)
await self._client.send_message(message, icon_path=icon_path)
except WebOsTvPairError:
_LOGGER.error("Pairing with TV failed")

View File

@ -36,6 +36,21 @@ async def test_notify(hass, client):
assert client.connect.call_count == 1
client.send_message.assert_called_with(MESSAGE, icon_path=ICON_PATH)
await hass.services.async_call(
NOTIFY_DOMAIN,
TV_NAME,
{
ATTR_MESSAGE: MESSAGE,
CONF_SERVICE_DATA: {
"OTHER_DATA": "not_used",
},
},
blocking=True,
)
assert client.mock_calls[0] == call.connect()
assert client.connect.call_count == 1
client.send_message.assert_called_with(MESSAGE, icon_path=None)
async def test_notify_not_connected(hass, client, monkeypatch):
"""Test sending a message when client is not connected."""