Add type hints to integration tests (part 12) (#87997)

This commit is contained in:
epenet
2023-02-13 13:03:51 +01:00
committed by GitHub
parent 896dd1a36b
commit ea29cdfe83
51 changed files with 371 additions and 246 deletions

View File

@@ -96,7 +96,7 @@ async def _device_form(hass, flow_id, connection, user_input):
return result, mock_setup, mock_setup_entry
async def test_form_select_modem(hass: HomeAssistant):
async def test_form_select_modem(hass: HomeAssistant) -> None:
"""Test we get a modem form."""
result = await _init_form(hass, HUB2)
@@ -104,7 +104,7 @@ async def test_form_select_modem(hass: HomeAssistant):
assert result["type"] == "form"
async def test_fail_on_existing(hass: HomeAssistant):
async def test_fail_on_existing(hass: HomeAssistant) -> None:
"""Test we fail if the integration is already configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -124,7 +124,7 @@ async def test_fail_on_existing(hass: HomeAssistant):
assert result["reason"] == "single_instance_allowed"
async def test_form_select_plm(hass: HomeAssistant):
async def test_form_select_plm(hass: HomeAssistant) -> None:
"""Test we set up the PLM correctly."""
result = await _init_form(hass, PLM)
@@ -139,7 +139,7 @@ async def test_form_select_plm(hass: HomeAssistant):
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_select_hub_v1(hass: HomeAssistant):
async def test_form_select_hub_v1(hass: HomeAssistant) -> None:
"""Test we set up the Hub v1 correctly."""
result = await _init_form(hass, HUB1)
@@ -157,7 +157,7 @@ async def test_form_select_hub_v1(hass: HomeAssistant):
assert len(mock_setup_entry.mock_calls) == 1
async def test_form_select_hub_v2(hass: HomeAssistant):
async def test_form_select_hub_v2(hass: HomeAssistant) -> None:
"""Test we set up the Hub v2 correctly."""
result = await _init_form(hass, HUB2)
@@ -175,7 +175,7 @@ async def test_form_select_hub_v2(hass: HomeAssistant):
assert len(mock_setup_entry.mock_calls) == 1
async def test_failed_connection_plm(hass: HomeAssistant):
async def test_failed_connection_plm(hass: HomeAssistant) -> None:
"""Test a failed connection with the PLM."""
result = await _init_form(hass, PLM)
@@ -187,7 +187,7 @@ async def test_failed_connection_plm(hass: HomeAssistant):
assert result2["errors"] == {"base": "cannot_connect"}
async def test_failed_connection_hub(hass: HomeAssistant):
async def test_failed_connection_hub(hass: HomeAssistant) -> None:
"""Test a failed connection with a Hub."""
result = await _init_form(hass, HUB2)
@@ -212,7 +212,7 @@ async def _import_config(hass, config):
)
async def test_import_plm(hass: HomeAssistant):
async def test_import_plm(hass: HomeAssistant) -> None:
"""Test importing a minimum PLM config from yaml."""
result = await _import_config(hass, MOCK_IMPORT_CONFIG_PLM)
@@ -238,7 +238,7 @@ async def _options_init_form(hass, entry_id, step):
return result2
async def test_import_min_hub_v2(hass: HomeAssistant):
async def test_import_min_hub_v2(hass: HomeAssistant) -> None:
"""Test importing a minimum Hub v2 config from yaml."""
result = await _import_config(
@@ -255,7 +255,7 @@ async def test_import_min_hub_v2(hass: HomeAssistant):
assert entry.data[CONF_HUB_VERSION] == 2
async def test_import_min_hub_v1(hass: HomeAssistant):
async def test_import_min_hub_v1(hass: HomeAssistant) -> None:
"""Test importing a minimum Hub v1 config from yaml."""
result = await _import_config(
@@ -270,7 +270,7 @@ async def test_import_min_hub_v1(hass: HomeAssistant):
assert entry.data[CONF_HUB_VERSION] == 1
async def test_import_existing(hass: HomeAssistant):
async def test_import_existing(hass: HomeAssistant) -> None:
"""Test we fail on an existing config imported."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -288,7 +288,7 @@ async def test_import_existing(hass: HomeAssistant):
assert result["reason"] == "single_instance_allowed"
async def test_import_failed_connection(hass: HomeAssistant):
async def test_import_failed_connection(hass: HomeAssistant) -> None:
"""Test a failed connection on import."""
with patch(
@@ -315,7 +315,7 @@ async def _options_form(hass, flow_id, user_input):
return result, mock_setup_entry
async def test_options_change_hub_config(hass: HomeAssistant):
async def test_options_change_hub_config(hass: HomeAssistant) -> None:
"""Test changing Hub v2 config."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -342,7 +342,7 @@ async def test_options_change_hub_config(hass: HomeAssistant):
assert config_entry.data == {**user_input, CONF_HUB_VERSION: 2}
async def test_options_change_plm_config(hass: HomeAssistant):
async def test_options_change_plm_config(hass: HomeAssistant) -> None:
"""Test changing PLM config."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -364,7 +364,7 @@ async def test_options_change_plm_config(hass: HomeAssistant):
assert config_entry.data == user_input
async def test_options_add_device_override(hass: HomeAssistant):
async def test_options_add_device_override(hass: HomeAssistant) -> None:
"""Test adding a device override."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -407,7 +407,7 @@ async def test_options_add_device_override(hass: HomeAssistant):
assert result["data"] != result3["data"]
async def test_options_remove_device_override(hass: HomeAssistant):
async def test_options_remove_device_override(hass: HomeAssistant) -> None:
"""Test removing a device override."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -431,7 +431,7 @@ async def test_options_remove_device_override(hass: HomeAssistant):
assert len(config_entry.options[CONF_OVERRIDE]) == 1
async def test_options_remove_device_override_with_x10(hass: HomeAssistant):
async def test_options_remove_device_override_with_x10(hass: HomeAssistant) -> None:
"""Test removing a device override when an X10 device is configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -464,7 +464,7 @@ async def test_options_remove_device_override_with_x10(hass: HomeAssistant):
assert len(config_entry.options[CONF_X10]) == 1
async def test_options_add_x10_device(hass: HomeAssistant):
async def test_options_add_x10_device(hass: HomeAssistant) -> None:
"""Test adding an X10 device."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -511,7 +511,7 @@ async def test_options_add_x10_device(hass: HomeAssistant):
assert result2["data"] != result3["data"]
async def test_options_remove_x10_device(hass: HomeAssistant):
async def test_options_remove_x10_device(hass: HomeAssistant) -> None:
"""Test removing an X10 device."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -545,7 +545,7 @@ async def test_options_remove_x10_device(hass: HomeAssistant):
assert len(config_entry.options[CONF_X10]) == 1
async def test_options_remove_x10_device_with_override(hass: HomeAssistant):
async def test_options_remove_x10_device_with_override(hass: HomeAssistant) -> None:
"""Test removing an X10 device when a device override is configured."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -581,7 +581,7 @@ async def test_options_remove_x10_device_with_override(hass: HomeAssistant):
assert len(config_entry.options[CONF_OVERRIDE]) == 1
async def test_options_dup_selection(hass: HomeAssistant):
async def test_options_dup_selection(hass: HomeAssistant) -> None:
"""Test if a duplicate selection was made in options."""
config_entry = MockConfigEntry(
domain=DOMAIN,
@@ -603,7 +603,7 @@ async def test_options_dup_selection(hass: HomeAssistant):
assert result2["errors"] == {"base": "select_single"}
async def test_options_override_bad_data(hass: HomeAssistant):
async def test_options_override_bad_data(hass: HomeAssistant) -> None:
"""Test for bad data in a device override."""
config_entry = MockConfigEntry(