Fix tests for Python 3.8 (#34672)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-04-25 14:32:55 -07:00
1 parent d53cb951e7
commit 0d700f6a63
40 files changed
+248 -285

No files matched your search

+7 -11
View File
@@ -1,24 +1,21 @@
"""Tests for the Hisense AEH-W4A1 init file."""
from unittest.mock import patch
from asynctest import patch
from pyaehw4a1 import exceptions
from homeassistant import config_entries, data_entry_flow
from homeassistant.components import hisense_aehw4a1
from homeassistant.setup import async_setup_component
from tests.common import mock_coro
async def test_creating_entry_sets_up_climate_discovery(hass):
"""Test setting up Hisense AEH-W4A1 loads the climate component."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.discovery",
return_value=mock_coro(["1.2.3.4"]),
return_value=["1.2.3.4"],
):
with patch(
"homeassistant.components.hisense_aehw4a1.climate.async_setup_entry",
return_value=mock_coro(True),
return_value=True,
) as mock_setup:
result = await hass.config_entries.flow.async_init(
hisense_aehw4a1.DOMAIN, context={"source": config_entries.SOURCE_USER}
@@ -41,11 +38,11 @@ async def test_configuring_hisense_w4a1_create_entry(hass):
"""Test that specifying config will create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check",
return_value=mock_coro(True),
return_value=True,
):
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=mock_coro(True),
return_value=True,
) as mock_setup:
await async_setup_component(
hass,
@@ -65,7 +62,7 @@ async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(h
):
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=mock_coro(True),
return_value=True,
) as mock_setup:
await async_setup_component(
hass,
@@ -80,8 +77,7 @@ async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(h
async def test_configuring_hisense_w4a1_not_creates_entry_for_empty_import(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=mock_coro(True),
"homeassistant.components.hisense_aehw4a1.async_setup_entry", return_value=True,
) as mock_setup:
await async_setup_component(hass, hisense_aehw4a1.DOMAIN, {})
await hass.async_block_till_done()