* Update return signature of service calls * Add timeout error handling in websocket api for service calls * Update recorder tests to remove assertion on service call * Remove timeout behavior and update callers that depend on it today * Fix tests * Add missing else * await coro directly * Fix more tests * Update the intent task to use wait instead of timeout * Remove script service call limits and limit constants * Update tests that depend on service call limits * Use wait instead of wait_for and add test * Update homeassistant/helpers/intent.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Tests for Plex buttons."""
|
|
from datetime import timedelta
|
|
from unittest.mock import patch
|
|
|
|
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
|
from homeassistant.components.plex.const import DEBOUNCE_TIMEOUT
|
|
from homeassistant.const import ATTR_ENTITY_ID
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.util import dt as dt_util
|
|
|
|
from tests.common import async_fire_time_changed
|
|
|
|
|
|
async def test_scan_clients_button_schedule(
|
|
hass: HomeAssistant, setup_plex_server
|
|
) -> None:
|
|
"""Test scan_clients button scheduled update."""
|
|
with patch(
|
|
"homeassistant.components.plex.server.PlexServer._async_update_platforms"
|
|
) as mock_scan_clients:
|
|
await setup_plex_server()
|
|
mock_scan_clients.reset_mock()
|
|
|
|
async_fire_time_changed(
|
|
hass,
|
|
dt_util.utcnow() + timedelta(seconds=DEBOUNCE_TIMEOUT),
|
|
)
|
|
|
|
await hass.services.async_call(
|
|
BUTTON_DOMAIN,
|
|
SERVICE_PRESS,
|
|
{
|
|
ATTR_ENTITY_ID: "button.scan_clients_plex_server_1",
|
|
},
|
|
True,
|
|
)
|
|
await hass.async_block_till_done()
|
|
|
|
assert mock_scan_clients.called
|