Ensure async_setup is mocked in geonetnz intergration tests (#37426)

* Ensure async_setup is mocked in geonetnz intergration tests

* s/asynctest/tests.async_mock/g
This commit is contained in:
J. Nick Koston 2020-07-03 13:14:19 -05:00 committed by GitHub
parent cd5f6a0c56
commit 3eb6a68d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 8 deletions

View File

@ -15,6 +15,8 @@ from homeassistant.const import (
CONF_UNIT_SYSTEM,
)
from tests.async_mock import patch
async def test_duplicate_error(hass, config_entry):
"""Test that errors are shown when duplicates are added."""
@ -49,9 +51,12 @@ async def test_step_import(hass):
CONF_MINIMUM_MAGNITUDE: 2.5,
}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "import"}, data=conf
)
with patch(
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "import"}, data=conf
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "-41.2, 174.7"
assert result["data"] == {
@ -71,9 +76,12 @@ async def test_step_user(hass):
hass.config.longitude = 174.7
conf = {CONF_RADIUS: 25, CONF_MMI: 4}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}, data=conf
)
with patch(
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
), patch("homeassistant.components.geonetnz_quakes.async_setup", return_value=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}, data=conf
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "-41.2, 174.7"
assert result["data"] == {

View File

@ -11,6 +11,8 @@ from homeassistant.const import (
CONF_UNIT_SYSTEM,
)
from tests.async_mock import patch
async def test_duplicate_error(hass, config_entry):
"""Test that errors are shown when duplicates are added."""
@ -48,7 +50,12 @@ async def test_step_import(hass):
flow = config_flow.GeonetnzVolcanoFlowHandler()
flow.hass = hass
result = await flow.async_step_import(import_config=conf)
with patch(
"homeassistant.components.geonetnz_volcano.async_setup_entry", return_value=True
), patch(
"homeassistant.components.geonetnz_volcano.async_setup", return_value=True
):
result = await flow.async_step_import(import_config=conf)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "-41.2, 174.7"
assert result["data"] == {
@ -69,7 +76,12 @@ async def test_step_user(hass):
flow = config_flow.GeonetnzVolcanoFlowHandler()
flow.hass = hass
result = await flow.async_step_user(user_input=conf)
with patch(
"homeassistant.components.geonetnz_volcano.async_setup_entry", return_value=True
), patch(
"homeassistant.components.geonetnz_volcano.async_setup", return_value=True
):
result = await flow.async_step_user(user_input=conf)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "-41.2, 174.7"
assert result["data"] == {