mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use return_value in Flu Near You config flow tests (#64596)
This commit is contained in:
parent
b2811cff51
commit
ff535053a9
@ -38,7 +38,7 @@ def data_cdc_fixture():
|
|||||||
async def setup_flunearyou_fixture(hass, config, data_cdc):
|
async def setup_flunearyou_fixture(hass, config, data_cdc):
|
||||||
"""Define a fixture to set up Flu Near You."""
|
"""Define a fixture to set up Flu Near You."""
|
||||||
with patch(
|
with patch(
|
||||||
"pyflunearyou.cdc.CdcReport.status_by_coordinates", side_effect=data_cdc
|
"pyflunearyou.cdc.CdcReport.status_by_coordinates", return_value=data_cdc
|
||||||
), patch("pyflunearyou.user.UserReport.status_by_coordinates"), patch(
|
), patch("pyflunearyou.user.UserReport.status_by_coordinates"), patch(
|
||||||
"homeassistant.components.flunearyou.PLATFORMS", []
|
"homeassistant.components.flunearyou.PLATFORMS", []
|
||||||
):
|
):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Define tests for the flunearyou config flow."""
|
"""Define tests for the flunearyou config flow."""
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pyflunearyou.errors import FluNearYouError
|
from pyflunearyou.errors import FluNearYouError
|
||||||
import pytest
|
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.flunearyou import DOMAIN
|
from homeassistant.components.flunearyou import DOMAIN
|
||||||
@ -17,9 +18,11 @@ async def test_duplicate_error(hass, config, config_entry, setup_flunearyou):
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("data_cdc", [FluNearYouError])
|
async def test_errors(hass, config):
|
||||||
async def test_errors(hass, config, data_cdc, setup_flunearyou):
|
|
||||||
"""Test that exceptions show the appropriate error."""
|
"""Test that exceptions show the appropriate error."""
|
||||||
|
with patch(
|
||||||
|
"pyflunearyou.cdc.CdcReport.status_by_coordinates", side_effect=FluNearYouError
|
||||||
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=config
|
DOMAIN, context={"source": SOURCE_USER}, data=config
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user