1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add service to scan for new Plex clients (#39074)

This commit is contained in:
jjlawren
2020-09-03 02:35:37 -05:00
committed by GitHub
parent 226406b853
commit aecd74c6af
4 changed files with 47 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ from homeassistant.components.plex.const import (
DOMAIN,
PLEX_SERVER_CONFIG,
SERVICE_REFRESH_LIBRARY,
SERVICE_SCAN_CLIENTS,
)
from homeassistant.const import (
CONF_HOST,
@@ -100,3 +101,28 @@ async def test_refresh_library(hass):
True,
)
assert not mock_update.called
async def test_scan_clients(hass):
"""Test scan_for_clients service call."""
entry = MockConfigEntry(
domain=DOMAIN,
data=DEFAULT_DATA,
options=DEFAULT_OPTIONS,
unique_id=DEFAULT_DATA["server_id"],
)
mock_plex_server = MockPlexServer(config_entry=entry)
with patch("plexapi.server.PlexServer", return_value=mock_plex_server), patch(
"plexapi.myplex.MyPlexAccount", return_value=MockPlexAccount()
), patch("homeassistant.components.plex.PlexWebsocket", autospec=True):
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert await hass.services.async_call(
DOMAIN,
SERVICE_SCAN_CLIENTS,
blocking=True,
)