Bump nettigo_air_monitor
to version 3.1.0 (#118227)
Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
This commit is contained in:
parent
e7ce01e649
commit
805f634634
7 changed files with 21 additions and 21 deletions
|
@ -5,9 +5,11 @@ from unittest.mock import AsyncMock, Mock, patch
|
|||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from nettigo_air_monitor import ApiError
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
from tenacity import RetryError
|
||||
|
||||
from homeassistant.components.nam.const import DOMAIN
|
||||
from homeassistant.components.nam.const import DEFAULT_UPDATE_INTERVAL, DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorDeviceClass
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
|
@ -96,7 +98,10 @@ async def test_incompleta_data_after_device_restart(hass: HomeAssistant) -> None
|
|||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_availability(hass: HomeAssistant) -> None:
|
||||
@pytest.mark.parametrize("exc", [ApiError("API Error"), RetryError])
|
||||
async def test_availability(
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, exc: Exception
|
||||
) -> None:
|
||||
"""Ensure that we mark the entities unavailable correctly when device causes an error."""
|
||||
nam_data = load_json_object_fixture("nam/nam_data.json")
|
||||
|
||||
|
@ -107,22 +112,21 @@ async def test_availability(hass: HomeAssistant) -> None:
|
|||
assert state.state != STATE_UNAVAILABLE
|
||||
assert state.state == "7.6"
|
||||
|
||||
future = utcnow() + timedelta(minutes=6)
|
||||
with (
|
||||
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
||||
patch(
|
||||
"homeassistant.components.nam.NettigoAirMonitor._async_http_request",
|
||||
side_effect=ApiError("API Error"),
|
||||
side_effect=exc,
|
||||
),
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
freezer.tick(DEFAULT_UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
||||
assert state
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
future = utcnow() + timedelta(minutes=12)
|
||||
update_response = Mock(json=AsyncMock(return_value=nam_data))
|
||||
with (
|
||||
patch("homeassistant.components.nam.NettigoAirMonitor.initialize"),
|
||||
|
@ -131,7 +135,8 @@ async def test_availability(hass: HomeAssistant) -> None:
|
|||
return_value=update_response,
|
||||
),
|
||||
):
|
||||
async_fire_time_changed(hass, future)
|
||||
freezer.tick(DEFAULT_UPDATE_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.nettigo_air_monitor_bme280_temperature")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue