Skip to content

Commit 9364a40

Browse files
authored
Bump fastdotcom to 0.0.6 (home-assistant#155354)
1 parent 7ead8f9 commit 9364a40

File tree

11 files changed

+54
-17
lines changed

11 files changed

+54
-17
lines changed

homeassistant/components/fastdotcom/coordinator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
type FastdotcomConfigEntry = ConfigEntry[FastdotcomDataUpdateCoordinator]
1616

1717

18-
class FastdotcomDataUpdateCoordinator(DataUpdateCoordinator[float]):
18+
class FastdotcomDataUpdateCoordinator(DataUpdateCoordinator[dict[str, float] | None]):
1919
"""Class to manage fetching Fast.com data API."""
2020

2121
def __init__(self, hass: HomeAssistant, entry: FastdotcomConfigEntry) -> None:
@@ -28,7 +28,7 @@ def __init__(self, hass: HomeAssistant, entry: FastdotcomConfigEntry) -> None:
2828
update_interval=timedelta(hours=DEFAULT_INTERVAL),
2929
)
3030

31-
async def _async_update_data(self) -> float:
31+
async def _async_update_data(self) -> dict[str, float] | None:
3232
"""Run an executor job to retrieve Fast.com data."""
3333
try:
3434
return await self.hass.async_add_executor_job(fast_com)

homeassistant/components/fastdotcom/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"integration_type": "service",
88
"iot_class": "cloud_polling",
99
"loggers": ["fastdotcom"],
10-
"requirements": ["fastdotcom==0.0.3"],
10+
"requirements": ["fastdotcom==0.0.6"],
1111
"single_config_entry": true
1212
}

homeassistant/components/fastdotcom/sensor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def __init__(
5151
@property
5252
def native_value(
5353
self,
54-
) -> float:
54+
) -> float | None:
5555
"""Return the state of the sensor."""
56-
return self.coordinator.data
56+
if self.coordinator.data is None:
57+
return None
58+
return self.coordinator.data.get("download_speed")

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
"""Fast.com integration tests."""
2+
3+
MOCK_DATA = {
4+
"download_speed": 100.0,
5+
"upload_speed": 50.0,
6+
"unloaded_ping": 15.2,
7+
"loaded_ping": 20.2,
8+
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# serializer version: 1
22
# name: test_get_config_entry_diagnostics
33
dict({
4-
'coordinator_data': 50.3,
4+
'coordinator_data': dict({
5+
'download_speed': 100.0,
6+
'loaded_ping': 20.2,
7+
'unloaded_ping': 15.2,
8+
'upload_speed': 50.0,
9+
}),
510
})
611
# ---

tests/components/fastdotcom/test_coordinator.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ async def test_fastdotcom_data_update_coordinator(
2424
)
2525
config_entry.add_to_hass(hass)
2626

27+
mock_data = {
28+
"download_speed": 5.0,
29+
"upload_speed": 50.0,
30+
"unloaded_ping": 15.2,
31+
"loaded_ping": 20.2,
32+
}
2733
with patch(
28-
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=5.0
34+
"homeassistant.components.fastdotcom.coordinator.fast_com",
35+
return_value=mock_data,
2936
):
3037
await hass.config_entries.async_setup(config_entry.entry_id)
3138
await hass.async_block_till_done()
@@ -34,8 +41,15 @@ async def test_fastdotcom_data_update_coordinator(
3441
assert state is not None
3542
assert state.state == "5.0"
3643

44+
mock_data = {
45+
"download_speed": 10.0,
46+
"upload_speed": 20.0,
47+
"unloaded_ping": 5.0,
48+
"loaded_ping": 20.0,
49+
}
3750
with patch(
38-
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=10.0
51+
"homeassistant.components.fastdotcom.coordinator.fast_com",
52+
return_value=mock_data,
3953
):
4054
freezer.tick(timedelta(hours=DEFAULT_INTERVAL))
4155
async_fire_time_changed(hass)

tests/components/fastdotcom/test_diagnostics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from homeassistant.config_entries import SOURCE_USER
99
from homeassistant.core import HomeAssistant
1010

11+
from . import MOCK_DATA
12+
1113
from tests.common import MockConfigEntry
1214
from tests.components.diagnostics import get_diagnostics_for_config_entry
1315
from tests.typing import ClientSessionGenerator
@@ -32,7 +34,8 @@ async def test_get_config_entry_diagnostics(
3234
config_entry.add_to_hass(hass)
3335

3436
with patch(
35-
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=50.3
37+
"homeassistant.components.fastdotcom.coordinator.fast_com",
38+
return_value=MOCK_DATA,
3639
):
3740
await hass.config_entries.async_setup(config_entry.entry_id)
3841
await hass.async_block_till_done()

tests/components/fastdotcom/test_init.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, STATE_UNKNOWN
1212
from homeassistant.core import CoreState, HomeAssistant
1313

14+
from . import MOCK_DATA
15+
1416
from tests.common import MockConfigEntry
1517

1618

@@ -24,7 +26,8 @@ async def test_unload_entry(hass: HomeAssistant) -> None:
2426
config_entry.add_to_hass(hass)
2527

2628
with patch(
27-
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=5.0
29+
"homeassistant.components.fastdotcom.coordinator.fast_com",
30+
return_value=MOCK_DATA,
2831
):
2932
await hass.config_entries.async_setup(config_entry.entry_id)
3033
await hass.async_block_till_done()
@@ -59,13 +62,13 @@ async def test_delayed_speedtest_during_startup(
5962
assert state.state is STATE_UNKNOWN
6063

6164
with patch(
62-
"homeassistant.components.fastdotcom.coordinator.fast_com", return_value=5.0
65+
"homeassistant.components.fastdotcom.coordinator.fast_com",
66+
return_value=MOCK_DATA,
6367
):
6468
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
6569
await hass.async_block_till_done()
6670

6771
state = hass.states.get("sensor.fast_com_download")
6872
assert state is not None
69-
assert state.state == "5.0"
70-
73+
assert state.state == "100.0"
7174
assert config_entry.state is ConfigEntryState.LOADED

0 commit comments

Comments
 (0)