Speedup Reolink tests by using scope="module" (#125215)

* use scope="module"

* Instead of side_effect = None, use reset_mock(side_efffect=True)

* fix tests
This commit is contained in:
starkillerOG
2024-09-23 12:50:40 +02:00
committed by GitHub
parent a9d12608bd
commit 8ef7cae36d
13 changed files with 101 additions and 12 deletions

View File

@@ -200,7 +200,7 @@ async def test_config_flow_errors(
assert result["step_id"] == "user"
assert result["errors"] == {CONF_HOST: "api_error"}
reolink_connect.get_host_data.side_effect = None
reolink_connect.get_host_data.reset_mock(side_effect=True)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
@@ -225,6 +225,9 @@ async def test_config_flow_errors(
CONF_PROTOCOL: DEFAULT_PROTOCOL,
}
reolink_connect.unsubscribe.reset_mock(side_effect=True)
reolink_connect.logout.reset_mock(side_effect=True)
async def test_options_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
"""Test specifying non default settings using options flow."""
@@ -478,6 +481,7 @@ async def test_dhcp_ip_update(
)
if attr is not None:
original = getattr(reolink_connect, attr)
setattr(reolink_connect, attr, value)
result = await hass.config_entries.flow.async_init(
@@ -508,6 +512,11 @@ async def test_dhcp_ip_update(
await hass.async_block_till_done()
assert config_entry.data[CONF_HOST] == expected
reolink_connect.get_states.side_effect = None
reolink_connect_class.reset_mock()
if attr is not None:
setattr(reolink_connect, attr, original)
async def test_reconfig(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
"""Test a reconfiguration flow."""