Fix timeout in purpleapi test (#88715)
https://github.com/home-assistant/core/actions/runs/4264644494/jobs/7423099757pull/88693/head^2
parent
69a3738bdb
commit
7b2e743a6b
|
@ -75,7 +75,7 @@ async def mock_aiopurpleair_fixture(api):
|
|||
with patch(
|
||||
"homeassistant.components.purpleair.config_flow.API", return_value=api
|
||||
), patch("homeassistant.components.purpleair.coordinator.API", return_value=api):
|
||||
yield
|
||||
yield api
|
||||
|
||||
|
||||
@pytest.fixture(name="setup_config_entry")
|
||||
|
|
|
@ -123,7 +123,7 @@ async def test_duplicate_error(
|
|||
)
|
||||
async def test_reauth(
|
||||
hass: HomeAssistant,
|
||||
api,
|
||||
mock_aiopurpleair,
|
||||
check_api_key_errors,
|
||||
check_api_key_mock,
|
||||
config_entry,
|
||||
|
@ -143,7 +143,7 @@ async def test_reauth(
|
|||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
# Test errors that can arise when checking the API key:
|
||||
with patch.object(api, "async_check_api_key", check_api_key_mock):
|
||||
with patch.object(mock_aiopurpleair, "async_check_api_key", check_api_key_mock):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"api_key": "new_api_key"}
|
||||
)
|
||||
|
@ -157,6 +157,9 @@ async def test_reauth(
|
|||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
# Unload to make sure the update does not run after the
|
||||
# mock is removed.
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -169,7 +172,7 @@ async def test_reauth(
|
|||
)
|
||||
async def test_options_add_sensor(
|
||||
hass: HomeAssistant,
|
||||
api,
|
||||
mock_aiopurpleair,
|
||||
config_entry,
|
||||
get_nearby_sensors_errors,
|
||||
get_nearby_sensors_mock,
|
||||
|
@ -187,7 +190,9 @@ async def test_options_add_sensor(
|
|||
assert result["step_id"] == "add_sensor"
|
||||
|
||||
# Test errors that can arise when searching for nearby sensors:
|
||||
with patch.object(api.sensors, "async_get_nearby_sensors", get_nearby_sensors_mock):
|
||||
with patch.object(
|
||||
mock_aiopurpleair.sensors, "async_get_nearby_sensors", get_nearby_sensors_mock
|
||||
):
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
|
@ -225,6 +230,9 @@ async def test_options_add_sensor(
|
|||
TEST_SENSOR_INDEX1,
|
||||
TEST_SENSOR_INDEX2,
|
||||
]
|
||||
# Unload to make sure the update does not run after the
|
||||
# mock is removed.
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_options_add_sensor_duplicate(
|
||||
|
@ -260,6 +268,9 @@ async def test_options_add_sensor_duplicate(
|
|||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
# Unload to make sure the update does not run after the
|
||||
# mock is removed.
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_options_remove_sensor(
|
||||
|
@ -288,3 +299,6 @@ async def test_options_remove_sensor(
|
|||
}
|
||||
|
||||
assert config_entry.options["sensor_indices"] == []
|
||||
# Unload to make sure the update does not run after the
|
||||
# mock is removed.
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
|
Loading…
Reference in New Issue