Fix tests for Python 3.8 (#34672)
This commit is contained in:
1 parent
d53cb951e7
commit
0d700f6a63
40 files changed
+248
-285
No files matched your search
@@ -4,7 +4,8 @@ from contextlib import contextmanager
|
||||
from datetime import timedelta
|
||||
import json
|
||||
import logging
|
||||
from unittest.mock import patch
|
||||
|
||||
from asynctest import patch
|
||||
|
||||
from homeassistant.components.awair.sensor import (
|
||||
ATTR_LAST_API_UPDATE,
|
||||
@@ -28,7 +29,7 @@ from homeassistant.const import (
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import parse_datetime, utcnow
|
||||
|
||||
from tests.common import async_fire_time_changed, load_fixture, mock_coro
|
||||
from tests.common import async_fire_time_changed, load_fixture
|
||||
|
||||
DISCOVERY_CONFIG = {"sensor": {"platform": "awair", "access_token": "qwerty"}}
|
||||
|
||||
@@ -68,9 +69,9 @@ def alter_time(retval):
|
||||
async def setup_awair(hass, config=None, data_fixture=AIR_DATA_FIXTURE):
|
||||
"""Load the Awair platform."""
|
||||
devices_json = json.loads(load_fixture("awair_devices.json"))
|
||||
devices_mock = mock_coro(devices_json)
|
||||
devices_mock = devices_json
|
||||
devices_patch = patch("python_awair.AwairClient.devices", return_value=devices_mock)
|
||||
air_data_mock = mock_coro(data_fixture)
|
||||
air_data_mock = data_fixture
|
||||
air_data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest", return_value=air_data_mock
|
||||
)
|
||||
@@ -233,8 +234,7 @@ async def test_availability(hass):
|
||||
|
||||
future = NOW + timedelta(minutes=30)
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE),
|
||||
"python_awair.AwairClient.air_data_latest", return_value=AIR_DATA_FIXTURE,
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
@@ -246,9 +246,7 @@ async def test_availability(hass):
|
||||
future = NOW + timedelta(hours=1)
|
||||
fixture = AIR_DATA_FIXTURE_UPDATED
|
||||
fixture[0][ATTR_TIMESTAMP] = str(future)
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest", return_value=mock_coro(fixture)
|
||||
)
|
||||
data_patch = patch("python_awair.AwairClient.air_data_latest", return_value=fixture)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -258,9 +256,7 @@ async def test_availability(hass):
|
||||
|
||||
future = NOW + timedelta(minutes=90)
|
||||
fixture = AIR_DATA_FIXTURE_EMPTY
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest", return_value=mock_coro(fixture)
|
||||
)
|
||||
data_patch = patch("python_awair.AwairClient.air_data_latest", return_value=fixture)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
async_fire_time_changed(hass, future)
|
||||
@@ -276,7 +272,7 @@ async def test_async_update(hass):
|
||||
future = NOW + timedelta(minutes=10)
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED),
|
||||
return_value=AIR_DATA_FIXTURE_UPDATED,
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
@@ -300,7 +296,7 @@ async def test_throttle_async_update(hass):
|
||||
future = NOW + timedelta(minutes=1)
|
||||
data_patch = patch(
|
||||
"python_awair.AwairClient.air_data_latest",
|
||||
return_value=mock_coro(AIR_DATA_FIXTURE_UPDATED),
|
||||
return_value=AIR_DATA_FIXTURE_UPDATED,
|
||||
)
|
||||
|
||||
with data_patch, alter_time(future):
|
||||
|
||||
Reference in new issue
Block a user