Deprecate speedtest service (#77261)

deprecate speedtest service
This commit is contained in:
Rami Mosleh 2022-08-26 21:57:43 +03:00 committed by GitHub
parent 5af015dd7d
commit b36321988f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 0 deletions

View file

@ -1,7 +1,11 @@
"""Tests for SpeedTest integration."""
from collections.abc import Awaitable
from datetime import timedelta
from typing import Callable
from unittest.mock import MagicMock
from aiohttp import ClientWebSocketResponse
import speedtest
from homeassistant.components.speedtestdotnet.const import (
@ -17,6 +21,7 @@ from homeassistant.core import HomeAssistant
import homeassistant.util.dt as dt_util
from tests.common import MockConfigEntry, async_fire_time_changed
from tests.components.repairs import get_repairs
async def test_successful_config_entry(hass: HomeAssistant) -> None:
@ -120,3 +125,28 @@ async def test_get_best_server_error(hass: HomeAssistant, mock_api: MagicMock) -
state = hass.states.get("sensor.speedtest_ping")
assert state is not None
assert state.state == STATE_UNAVAILABLE
async def test_deprecated_service_alert(
hass: HomeAssistant,
hass_ws_client: Callable[[HomeAssistant], Awaitable[ClientWebSocketResponse]],
) -> None:
"""Test that an issue is raised if deprecated services is called."""
entry = MockConfigEntry(
domain=DOMAIN,
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
await hass.services.async_call(
DOMAIN,
"speedtest",
{},
blocking=True,
)
await hass.async_block_till_done()
issues = await get_repairs(hass, hass_ws_client)
assert len(issues) == 1
assert issues[0]["issue_id"] == "deprecated_service"