Move hangouts imports at top-level (#29055)
This commit is contained in:
parent
1fde0d18ed
commit
112a3f5e9f
4 changed files with 50 additions and 48 deletions
|
@ -4,6 +4,10 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.hangouts import config_flow
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
|
||||
EMAIL = "test@test.com"
|
||||
PASSWORD = "1232456"
|
||||
|
||||
|
||||
async def test_flow_works(hass, aioclient_mock):
|
||||
|
@ -12,12 +16,12 @@ async def test_flow_works(hass, aioclient_mock):
|
|||
|
||||
flow.hass = hass
|
||||
|
||||
with patch("hangups.get_auth"):
|
||||
with patch("homeassistant.components.hangouts.config_flow.get_auth"):
|
||||
result = await flow.async_step_user(
|
||||
{"email": "test@test.com", "password": "1232456"}
|
||||
{CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "test@test.com"
|
||||
assert result["title"] == EMAIL
|
||||
|
||||
|
||||
async def test_flow_works_with_authcode(hass, aioclient_mock):
|
||||
|
@ -26,16 +30,16 @@ async def test_flow_works_with_authcode(hass, aioclient_mock):
|
|||
|
||||
flow.hass = hass
|
||||
|
||||
with patch("hangups.get_auth"):
|
||||
with patch("homeassistant.components.hangouts.config_flow.get_auth"):
|
||||
result = await flow.async_step_user(
|
||||
{
|
||||
"email": "test@test.com",
|
||||
"password": "1232456",
|
||||
CONF_EMAIL: EMAIL,
|
||||
CONF_PASSWORD: PASSWORD,
|
||||
"authorization_code": "c29tZXJhbmRvbXN0cmluZw==",
|
||||
}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "test@test.com"
|
||||
assert result["title"] == EMAIL
|
||||
|
||||
|
||||
async def test_flow_works_with_2fa(hass, aioclient_mock):
|
||||
|
@ -46,17 +50,20 @@ async def test_flow_works_with_2fa(hass, aioclient_mock):
|
|||
|
||||
flow.hass = hass
|
||||
|
||||
with patch("hangups.get_auth", side_effect=Google2FAError):
|
||||
with patch(
|
||||
"homeassistant.components.hangouts.config_flow.get_auth",
|
||||
side_effect=Google2FAError,
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
{"email": "test@test.com", "password": "1232456"}
|
||||
{CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "2fa"
|
||||
|
||||
with patch("hangups.get_auth"):
|
||||
with patch("homeassistant.components.hangouts.config_flow.get_auth"):
|
||||
result = await flow.async_step_2fa({"2fa": 123456})
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "test@test.com"
|
||||
assert result["title"] == EMAIL
|
||||
|
||||
|
||||
async def test_flow_with_unknown_2fa(hass, aioclient_mock):
|
||||
|
@ -68,11 +75,11 @@ async def test_flow_with_unknown_2fa(hass, aioclient_mock):
|
|||
flow.hass = hass
|
||||
|
||||
with patch(
|
||||
"hangups.get_auth",
|
||||
"homeassistant.components.hangouts.config_flow.get_auth",
|
||||
side_effect=GoogleAuthError("Unknown verification code input"),
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
{"email": "test@test.com", "password": "1232456"}
|
||||
{CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"]["base"] == "invalid_2fa_method"
|
||||
|
@ -86,9 +93,12 @@ async def test_flow_invalid_login(hass, aioclient_mock):
|
|||
|
||||
flow.hass = hass
|
||||
|
||||
with patch("hangups.get_auth", side_effect=GoogleAuthError):
|
||||
with patch(
|
||||
"homeassistant.components.hangouts.config_flow.get_auth",
|
||||
side_effect=GoogleAuthError,
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
{"email": "test@test.com", "password": "1232456"}
|
||||
{CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"]["base"] == "invalid_login"
|
||||
|
@ -102,14 +112,20 @@ async def test_flow_invalid_2fa(hass, aioclient_mock):
|
|||
|
||||
flow.hass = hass
|
||||
|
||||
with patch("hangups.get_auth", side_effect=Google2FAError):
|
||||
with patch(
|
||||
"homeassistant.components.hangouts.config_flow.get_auth",
|
||||
side_effect=Google2FAError,
|
||||
):
|
||||
result = await flow.async_step_user(
|
||||
{"email": "test@test.com", "password": "1232456"}
|
||||
{CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "2fa"
|
||||
|
||||
with patch("hangups.get_auth", side_effect=Google2FAError):
|
||||
with patch(
|
||||
"homeassistant.components.hangouts.config_flow.get_auth",
|
||||
side_effect=Google2FAError,
|
||||
):
|
||||
result = await flow.async_step_2fa({"2fa": 123456})
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue