Skip to content

Commit

Permalink
instead of creating a task, await the async_call and expect the excep…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
ziv1234 committed Apr 5, 2020
1 parent c8df5fb commit 4ced55b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 11 additions & 7 deletions tests/components/rflink/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

from unittest.mock import Mock

import pytest
from voluptuous.error import MultipleInvalid

from homeassistant.bootstrap import async_setup_component
from homeassistant.components.rflink import (
CONF_RECONNECT_INTERVAL,
Expand Down Expand Up @@ -169,16 +172,17 @@ async def test_send_command_invalid_arguments(hass, monkeypatch):
_, _, protocol, _ = await mock_rflink(hass, config, domain, monkeypatch)

# one argument missing
hass.async_create_task(
hass.services.async_call(domain, SERVICE_SEND_COMMAND, {"command": "on"})
)
hass.async_create_task(
hass.services.async_call(
with pytest.raises(MultipleInvalid):
await hass.services.async_call(domain, SERVICE_SEND_COMMAND, {"command": "on"})

with pytest.raises(MultipleInvalid):
await hass.services.async_call(
domain, SERVICE_SEND_COMMAND, {"device_id": "newkaku_0000c6c2_1"}
)
)

# no arguments
hass.async_create_task(hass.services.async_call(domain, SERVICE_SEND_COMMAND, {}))
with pytest.raises(MultipleInvalid):
await hass.services.async_call(domain, SERVICE_SEND_COMMAND, {})

await hass.async_block_till_done()
assert protocol.send_command_ack.call_args_list == []
Expand Down
1 change: 0 additions & 1 deletion tests/ignore_uncaught_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
("tests.components.local_file.test_camera", "test_file_not_readable"),
("tests.components.qwikswitch.test_init", "test_binary_sensor_device"),
("tests.components.qwikswitch.test_init", "test_sensor_device"),
("tests.components.rflink.test_init", "test_send_command_invalid_arguments"),
("tests.components.samsungtv.test_media_player", "test_update_connection_failure"),
(
"tests.components.tplink.test_init",
Expand Down

0 comments on commit 4ced55b

Please sign in to comment.