Fix static/class async mocks on Python 3.8.0 and .1 (#40147)
* forked_daapd * shelly * simplipy
This commit is contained in:
1 parent
f6584c1866
commit
271ffac4a9
3 files changed
+47
-27
No files matched your search
@@ -10,7 +10,7 @@ from homeassistant.components.simplisafe import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.const import CONF_CODE, CONF_PASSWORD, CONF_TOKEN, CONF_USERNAME
|
||||
|
||||
from tests.async_mock import MagicMock, PropertyMock, patch
|
||||
from tests.async_mock import AsyncMock, MagicMock, PropertyMock, patch
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ async def test_invalid_credentials(hass):
|
||||
|
||||
with patch(
|
||||
"simplipy.API.login_via_credentials",
|
||||
side_effect=InvalidCredentialsError,
|
||||
new=AsyncMock(side_effect=InvalidCredentialsError),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||
@@ -105,7 +105,9 @@ async def test_step_import(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.simplisafe.async_setup_entry", return_value=True
|
||||
), patch("simplipy.API.login_via_credentials", return_value=mock_api()):
|
||||
), patch(
|
||||
"simplipy.API.login_via_credentials", new=AsyncMock(return_value=mock_api())
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||
)
|
||||
@@ -140,7 +142,9 @@ async def test_step_reauth(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.simplisafe.async_setup_entry", return_value=True
|
||||
), patch("simplipy.API.login_via_credentials", return_value=mock_api()):
|
||||
), patch(
|
||||
"simplipy.API.login_via_credentials", new=AsyncMock(return_value=mock_api())
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_PASSWORD: "password"}
|
||||
)
|
||||
@@ -160,7 +164,9 @@ async def test_step_user(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.simplisafe.async_setup_entry", return_value=True
|
||||
), patch("simplipy.API.login_via_credentials", return_value=mock_api()):
|
||||
), patch(
|
||||
"simplipy.API.login_via_credentials", new=AsyncMock(return_value=mock_api())
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||
)
|
||||
@@ -183,7 +189,8 @@ async def test_step_user_mfa(hass):
|
||||
}
|
||||
|
||||
with patch(
|
||||
"simplipy.API.login_via_credentials", side_effect=PendingAuthorizationError
|
||||
"simplipy.API.login_via_credentials",
|
||||
new=AsyncMock(side_effect=PendingAuthorizationError),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||
@@ -191,7 +198,8 @@ async def test_step_user_mfa(hass):
|
||||
assert result["step_id"] == "mfa"
|
||||
|
||||
with patch(
|
||||
"simplipy.API.login_via_credentials", side_effect=PendingAuthorizationError
|
||||
"simplipy.API.login_via_credentials",
|
||||
new=AsyncMock(side_effect=PendingAuthorizationError),
|
||||
):
|
||||
# Simulate the user pressing the MFA submit button without having clicked
|
||||
# the link in the MFA email:
|
||||
@@ -202,7 +210,9 @@ async def test_step_user_mfa(hass):
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.simplisafe.async_setup_entry", return_value=True
|
||||
), patch("simplipy.API.login_via_credentials", return_value=mock_api()):
|
||||
), patch(
|
||||
"simplipy.API.login_via_credentials", new=AsyncMock(return_value=mock_api())
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
@@ -222,7 +232,7 @@ async def test_unknown_error(hass):
|
||||
|
||||
with patch(
|
||||
"simplipy.API.login_via_credentials",
|
||||
side_effect=SimplipyError,
|
||||
new=AsyncMock(side_effect=SimplipyError),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||
|
||||
Reference in new issue
Block a user