1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Add entity translations to Dexcom (#98795)

This commit is contained in:
Joost Lekkerkerker
2023-08-22 22:09:18 +02:00
committed by GitHub
parent 57bc8ae68e
commit f10a5b7ee8
3 changed files with 29 additions and 36 deletions

View File

@@ -19,13 +19,9 @@ async def test_sensors(hass: HomeAssistant) -> None:
"""Test we get sensor data."""
await init_integration(hass)
test_username_glucose_value = hass.states.get(
"sensor.dexcom_test_username_glucose_value"
)
test_username_glucose_value = hass.states.get("sensor.test_username_glucose_value")
assert test_username_glucose_value.state == str(GLUCOSE_READING.value)
test_username_glucose_trend = hass.states.get(
"sensor.dexcom_test_username_glucose_trend"
)
test_username_glucose_trend = hass.states.get("sensor.test_username_glucose_trend")
assert test_username_glucose_trend.state == GLUCOSE_READING.trend_description
@@ -37,16 +33,12 @@ async def test_sensors_unknown(hass: HomeAssistant) -> None:
"homeassistant.components.dexcom.Dexcom.get_current_glucose_reading",
return_value=None,
):
await async_update_entity(hass, "sensor.dexcom_test_username_glucose_value")
await async_update_entity(hass, "sensor.dexcom_test_username_glucose_trend")
await async_update_entity(hass, "sensor.test_username_glucose_value")
await async_update_entity(hass, "sensor.test_username_glucose_trend")
test_username_glucose_value = hass.states.get(
"sensor.dexcom_test_username_glucose_value"
)
test_username_glucose_value = hass.states.get("sensor.test_username_glucose_value")
assert test_username_glucose_value.state == STATE_UNKNOWN
test_username_glucose_trend = hass.states.get(
"sensor.dexcom_test_username_glucose_trend"
)
test_username_glucose_trend = hass.states.get("sensor.test_username_glucose_trend")
assert test_username_glucose_trend.state == STATE_UNKNOWN
@@ -58,16 +50,12 @@ async def test_sensors_update_failed(hass: HomeAssistant) -> None:
"homeassistant.components.dexcom.Dexcom.get_current_glucose_reading",
side_effect=SessionError,
):
await async_update_entity(hass, "sensor.dexcom_test_username_glucose_value")
await async_update_entity(hass, "sensor.dexcom_test_username_glucose_trend")
await async_update_entity(hass, "sensor.test_username_glucose_value")
await async_update_entity(hass, "sensor.test_username_glucose_trend")
test_username_glucose_value = hass.states.get(
"sensor.dexcom_test_username_glucose_value"
)
test_username_glucose_value = hass.states.get("sensor.test_username_glucose_value")
assert test_username_glucose_value.state == STATE_UNAVAILABLE
test_username_glucose_trend = hass.states.get(
"sensor.dexcom_test_username_glucose_trend"
)
test_username_glucose_trend = hass.states.get("sensor.test_username_glucose_trend")
assert test_username_glucose_trend.state == STATE_UNAVAILABLE
@@ -75,13 +63,9 @@ async def test_sensors_options_changed(hass: HomeAssistant) -> None:
"""Test we handle sensor unavailable."""
entry = await init_integration(hass)
test_username_glucose_value = hass.states.get(
"sensor.dexcom_test_username_glucose_value"
)
test_username_glucose_value = hass.states.get("sensor.test_username_glucose_value")
assert test_username_glucose_value.state == str(GLUCOSE_READING.value)
test_username_glucose_trend = hass.states.get(
"sensor.dexcom_test_username_glucose_trend"
)
test_username_glucose_trend = hass.states.get("sensor.test_username_glucose_trend")
assert test_username_glucose_trend.state == GLUCOSE_READING.trend_description
with patch(
@@ -99,11 +83,7 @@ async def test_sensors_options_changed(hass: HomeAssistant) -> None:
assert entry.options == {CONF_UNIT_OF_MEASUREMENT: MMOL_L}
test_username_glucose_value = hass.states.get(
"sensor.dexcom_test_username_glucose_value"
)
test_username_glucose_value = hass.states.get("sensor.test_username_glucose_value")
assert test_username_glucose_value.state == str(GLUCOSE_READING.mmol_l)
test_username_glucose_trend = hass.states.get(
"sensor.dexcom_test_username_glucose_trend"
)
test_username_glucose_trend = hass.states.get("sensor.test_username_glucose_trend")
assert test_username_glucose_trend.state == GLUCOSE_READING.trend_description