Add type hints in samsungtv tests (#66632)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
44befe5f11
commit
6d0a06c57a
4 changed files with 185 additions and 119 deletions
|
@ -2,6 +2,7 @@
|
|||
import socket
|
||||
from unittest.mock import Mock, call, patch
|
||||
|
||||
import pytest
|
||||
from samsungctl.exceptions import AccessDenied, UnhandledResponse
|
||||
from samsungtvws import SamsungTVWS
|
||||
from samsungtvws.exceptions import ConnectionFailure, HttpApiError
|
||||
|
@ -182,7 +183,8 @@ DEVICEINFO_WEBSOCKET_SSL = {
|
|||
}
|
||||
|
||||
|
||||
async def test_user_legacy(hass: HomeAssistant, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_user_legacy(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user."""
|
||||
# show form
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -206,7 +208,8 @@ async def test_user_legacy(hass: HomeAssistant, remote: Mock):
|
|||
assert result["result"].unique_id is None
|
||||
|
||||
|
||||
async def test_user_websocket(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_user_websocket(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote", side_effect=OSError("Boom")
|
||||
|
@ -233,7 +236,8 @@ async def test_user_websocket(hass: HomeAssistant, remotews: Mock):
|
|||
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_user_legacy_missing_auth(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_user_legacy_missing_auth(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user with authentication."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -247,7 +251,7 @@ async def test_user_legacy_missing_auth(hass: HomeAssistant, remotews: Mock):
|
|||
assert result["reason"] == RESULT_AUTH_MISSING
|
||||
|
||||
|
||||
async def test_user_legacy_not_supported(hass: HomeAssistant):
|
||||
async def test_user_legacy_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user for not supported device."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -261,7 +265,7 @@ async def test_user_legacy_not_supported(hass: HomeAssistant):
|
|||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
async def test_user_websocket_not_supported(hass: HomeAssistant):
|
||||
async def test_user_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user for not supported device."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -278,7 +282,7 @@ async def test_user_websocket_not_supported(hass: HomeAssistant):
|
|||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
async def test_user_not_successful(hass: HomeAssistant):
|
||||
async def test_user_not_successful(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user but no connection found."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -294,7 +298,7 @@ async def test_user_not_successful(hass: HomeAssistant):
|
|||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
async def test_user_not_successful_2(hass: HomeAssistant):
|
||||
async def test_user_not_successful_2(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow by user but no connection found."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -310,7 +314,8 @@ async def test_user_not_successful_2(hass: HomeAssistant):
|
|||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
async def test_ssdp(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_ssdp(hass: HomeAssistant, no_mac_address: Mock) -> None:
|
||||
"""Test starting a flow from discovery."""
|
||||
|
||||
no_mac_address.return_value = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -338,7 +343,8 @@ async def test_ssdp(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
|||
assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_ssdp_noprefix(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_ssdp_noprefix(hass: HomeAssistant, no_mac_address: Mock) -> None:
|
||||
"""Test starting a flow from discovery without prefixes."""
|
||||
|
||||
no_mac_address.return_value = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -373,7 +379,8 @@ async def test_ssdp_noprefix(hass: HomeAssistant, remote: Mock, no_mac_address:
|
|||
assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172df"
|
||||
|
||||
|
||||
async def test_ssdp_legacy_missing_auth(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_ssdp_legacy_missing_auth(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery with authentication."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -400,9 +407,8 @@ async def test_ssdp_legacy_missing_auth(hass: HomeAssistant, remotews: Mock):
|
|||
assert result["reason"] == RESULT_AUTH_MISSING
|
||||
|
||||
|
||||
async def test_ssdp_legacy_not_supported(
|
||||
hass: HomeAssistant, remote: Mock, remotews: Mock
|
||||
):
|
||||
@pytest.mark.usefixtures("remote", "remotews")
|
||||
async def test_ssdp_legacy_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery for not supported device."""
|
||||
|
||||
# confirm to add the entry
|
||||
|
@ -424,11 +430,10 @@ async def test_ssdp_legacy_not_supported(
|
|||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote", "remotews")
|
||||
async def test_ssdp_websocket_success_populates_mac_address(
|
||||
hass: HomeAssistant,
|
||||
remote: Mock,
|
||||
remotews: Mock,
|
||||
):
|
||||
) -> None:
|
||||
"""Test starting a flow from ssdp for a supported device populates the mac."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
|
@ -449,7 +454,7 @@ async def test_ssdp_websocket_success_populates_mac_address(
|
|||
assert result["result"].unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_ssdp_websocket_not_supported(hass: HomeAssistant):
|
||||
async def test_ssdp_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery for not supported device."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -467,7 +472,8 @@ async def test_ssdp_websocket_not_supported(hass: HomeAssistant):
|
|||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
async def test_ssdp_model_not_supported(hass: HomeAssistant, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_ssdp_model_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery."""
|
||||
|
||||
# confirm to add the entry
|
||||
|
@ -480,7 +486,8 @@ async def test_ssdp_model_not_supported(hass: HomeAssistant, remote: Mock):
|
|||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
async def test_ssdp_not_successful(hass: HomeAssistant, no_mac_address: Mock):
|
||||
@pytest.mark.usefixtures("no_mac_address")
|
||||
async def test_ssdp_not_successful(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery but no device found."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -508,7 +515,8 @@ async def test_ssdp_not_successful(hass: HomeAssistant, no_mac_address: Mock):
|
|||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
async def test_ssdp_not_successful_2(hass: HomeAssistant, no_mac_address: Mock):
|
||||
@pytest.mark.usefixtures("no_mac_address")
|
||||
async def test_ssdp_not_successful_2(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from discovery but no device found."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -536,9 +544,10 @@ async def test_ssdp_not_successful_2(hass: HomeAssistant, no_mac_address: Mock):
|
|||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_ssdp_already_in_progress(
|
||||
hass: HomeAssistant, remote: Mock, no_mac_address: Mock
|
||||
):
|
||||
hass: HomeAssistant, no_mac_address: Mock
|
||||
) -> None:
|
||||
"""Test starting a flow from discovery twice."""
|
||||
|
||||
no_mac_address.return_value = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -562,9 +571,10 @@ async def test_ssdp_already_in_progress(
|
|||
assert result["reason"] == RESULT_ALREADY_IN_PROGRESS
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_ssdp_already_configured(
|
||||
hass: HomeAssistant, remote: Mock, no_mac_address: Mock
|
||||
):
|
||||
hass: HomeAssistant, no_mac_address: Mock
|
||||
) -> None:
|
||||
"""Test starting a flow from discovery when already configured."""
|
||||
|
||||
no_mac_address.return_value = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -594,7 +604,8 @@ async def test_ssdp_already_configured(
|
|||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_import_legacy(hass: HomeAssistant, remote: Mock, no_mac_address: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_import_legacy(hass: HomeAssistant, no_mac_address: Mock) -> None:
|
||||
"""Test importing from yaml with hostname."""
|
||||
|
||||
no_mac_address.return_value = "aa:bb:cc:dd:ee:ff"
|
||||
|
@ -617,12 +628,8 @@ async def test_import_legacy(hass: HomeAssistant, remote: Mock, no_mac_address:
|
|||
assert entries[0].data[CONF_PORT] == LEGACY_PORT
|
||||
|
||||
|
||||
async def test_import_legacy_without_name(
|
||||
hass: HomeAssistant,
|
||||
remote: Mock,
|
||||
remotews_no_device_info: Mock,
|
||||
no_mac_address: Mock,
|
||||
):
|
||||
@pytest.mark.usefixtures("remote", "remotews_no_device_info", "no_mac_address")
|
||||
async def test_import_legacy_without_name(hass: HomeAssistant) -> None:
|
||||
"""Test importing from yaml without a name."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -642,7 +649,8 @@ async def test_import_legacy_without_name(
|
|||
assert entries[0].data[CONF_PORT] == LEGACY_PORT
|
||||
|
||||
|
||||
async def test_import_websocket(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_import_websocket(hass: HomeAssistant):
|
||||
"""Test importing from yaml with hostname."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -660,7 +668,8 @@ async def test_import_websocket(hass: HomeAssistant, remotews: Mock):
|
|||
assert result["result"].unique_id is None
|
||||
|
||||
|
||||
async def test_import_websocket_without_port(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_import_websocket_without_port(hass: HomeAssistant):
|
||||
"""Test importing from yaml with hostname by no port."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -681,7 +690,8 @@ async def test_import_websocket_without_port(hass: HomeAssistant, remotews: Mock
|
|||
assert entries[0].data[CONF_PORT] == 8002
|
||||
|
||||
|
||||
async def test_import_unknown_host(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_import_unknown_host(hass: HomeAssistant):
|
||||
"""Test importing from yaml with hostname that does not resolve."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.config_flow.socket.gethostbyname",
|
||||
|
@ -697,7 +707,8 @@ async def test_import_unknown_host(hass: HomeAssistant, remotews: Mock):
|
|||
assert result["reason"] == RESULT_UNKNOWN_HOST
|
||||
|
||||
|
||||
async def test_dhcp(hass: HomeAssistant, remote: Mock, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remote", "remotews")
|
||||
async def test_dhcp(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from dhcp."""
|
||||
# confirm to add the entry
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
@ -723,7 +734,8 @@ async def test_dhcp(hass: HomeAssistant, remote: Mock, remotews: Mock):
|
|||
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_zeroconf(hass: HomeAssistant, remote: Mock, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remote", "remotews")
|
||||
async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from zeroconf."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -748,7 +760,8 @@ async def test_zeroconf(hass: HomeAssistant, remote: Mock, remotews: Mock):
|
|||
assert result["result"].unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, remotews_soundbar: Mock):
|
||||
@pytest.mark.usefixtures("remotews_soundbar")
|
||||
async def test_zeroconf_ignores_soundbar(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from zeroconf where the device is actually a soundbar."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -760,9 +773,8 @@ async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, remotews_soundbar:
|
|||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_zeroconf_no_device_info(
|
||||
hass: HomeAssistant, remote: Mock, remotews_no_device_info: Mock
|
||||
):
|
||||
@pytest.mark.usefixtures("remote", "remotews_no_device_info")
|
||||
async def test_zeroconf_no_device_info(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from zeroconf where device_info returns None."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -774,7 +786,8 @@ async def test_zeroconf_no_device_info(
|
|||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant) -> None:
|
||||
"""Test starting a flow from zeroconf and dhcp."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
|
@ -795,7 +808,7 @@ async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant, remotews: Mock):
|
|||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
async def test_autodetect_websocket(hass: HomeAssistant):
|
||||
async def test_autodetect_websocket(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -837,7 +850,7 @@ async def test_autodetect_websocket(hass: HomeAssistant):
|
|||
assert entries[0].data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
|
||||
|
||||
|
||||
async def test_websocket_no_mac(hass: HomeAssistant):
|
||||
async def test_websocket_no_mac(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -882,7 +895,7 @@ async def test_websocket_no_mac(hass: HomeAssistant):
|
|||
assert entries[0].data[CONF_MAC] == "gg:hh:ii:ll:mm:nn"
|
||||
|
||||
|
||||
async def test_autodetect_auth_missing(hass: HomeAssistant):
|
||||
async def test_autodetect_auth_missing(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -897,7 +910,7 @@ async def test_autodetect_auth_missing(hass: HomeAssistant):
|
|||
assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
|
||||
|
||||
|
||||
async def test_autodetect_not_supported(hass: HomeAssistant):
|
||||
async def test_autodetect_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
with patch(
|
||||
"homeassistant.components.samsungtv.bridge.Remote",
|
||||
|
@ -912,7 +925,8 @@ async def test_autodetect_not_supported(hass: HomeAssistant):
|
|||
assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
|
||||
|
||||
|
||||
async def test_autodetect_legacy(hass: HomeAssistant, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_autodetect_legacy(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
|
@ -924,7 +938,7 @@ async def test_autodetect_legacy(hass: HomeAssistant, remote: Mock):
|
|||
assert result["data"][CONF_PORT] == LEGACY_PORT
|
||||
|
||||
|
||||
async def test_autodetect_none(hass: HomeAssistant):
|
||||
async def test_autodetect_none(hass: HomeAssistant) -> None:
|
||||
"""Test for send key with autodetection of protocol."""
|
||||
mock_remotews = Mock()
|
||||
mock_remotews.__enter__ = Mock(return_value=mock_remotews)
|
||||
|
@ -954,7 +968,8 @@ async def test_autodetect_none(hass: HomeAssistant):
|
|||
]
|
||||
|
||||
|
||||
async def test_update_old_entry(hass: HomeAssistant, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_update_old_entry(hass: HomeAssistant) -> None:
|
||||
"""Test update of old entry."""
|
||||
with patch("homeassistant.components.samsungtv.bridge.Remote") as remote:
|
||||
remote().rest_device_info.return_value = {
|
||||
|
@ -995,7 +1010,10 @@ async def test_update_old_entry(hass: HomeAssistant, remotews: Mock):
|
|||
assert entry2.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_update_missing_mac_unique_id_added_from_dhcp(hass, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_update_missing_mac_unique_id_added_from_dhcp(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test missing mac and unique id added."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY, unique_id=None)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1021,7 +1039,10 @@ async def test_update_missing_mac_unique_id_added_from_dhcp(hass, remotews: Mock
|
|||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_update_missing_mac_unique_id_added_from_zeroconf(hass, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_update_missing_mac_unique_id_added_from_zeroconf(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test missing mac and unique id added."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY, unique_id=None)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1046,7 +1067,10 @@ async def test_update_missing_mac_unique_id_added_from_zeroconf(hass, remotews:
|
|||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
|
||||
|
||||
async def test_update_missing_mac_unique_id_added_from_ssdp(hass, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_update_missing_mac_unique_id_added_from_ssdp(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test missing mac and unique id added via ssdp."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY, unique_id=None)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1072,9 +1096,10 @@ async def test_update_missing_mac_unique_id_added_from_ssdp(hass, remotews: Mock
|
|||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_update_missing_mac_added_unique_id_preserved_from_zeroconf(
|
||||
hass, remotews: Mock
|
||||
):
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test missing mac and unique id added."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -1103,7 +1128,8 @@ async def test_update_missing_mac_added_unique_id_preserved_from_zeroconf(
|
|||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_update_legacy_missing_mac_from_dhcp(hass, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_update_legacy_missing_mac_from_dhcp(hass: HomeAssistant) -> None:
|
||||
"""Test missing mac added."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -1134,7 +1160,10 @@ async def test_update_legacy_missing_mac_from_dhcp(hass, remote: Mock):
|
|||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
||||
|
||||
async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(hass, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test missing mac added when there is no unique id."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
@ -1170,7 +1199,8 @@ async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(hass, remote: Mo
|
|||
assert entry.unique_id is None
|
||||
|
||||
|
||||
async def test_form_reauth_legacy(hass, remote: Mock):
|
||||
@pytest.mark.usefixtures("remote")
|
||||
async def test_form_reauth_legacy(hass: HomeAssistant) -> None:
|
||||
"""Test reauthenticate legacy."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_OLD_ENTRY)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1191,7 +1221,8 @@ async def test_form_reauth_legacy(hass, remote: Mock):
|
|||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
async def test_form_reauth_websocket(hass, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_form_reauth_websocket(hass: HomeAssistant) -> None:
|
||||
"""Test reauthenticate websocket."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_WS_ENTRY)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1215,7 +1246,8 @@ async def test_form_reauth_websocket(hass, remotews: Mock):
|
|||
assert entry.state == config_entries.ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_form_reauth_websocket_cannot_connect(hass, remotews: Mock):
|
||||
@pytest.mark.usefixtures("remotews")
|
||||
async def test_form_reauth_websocket_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"""Test reauthenticate websocket when we cannot connect on the first attempt."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_WS_ENTRY)
|
||||
entry.add_to_hass(hass)
|
||||
|
@ -1247,7 +1279,7 @@ async def test_form_reauth_websocket_cannot_connect(hass, remotews: Mock):
|
|||
assert result3["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
async def test_form_reauth_websocket_not_supported(hass):
|
||||
async def test_form_reauth_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
"""Test reauthenticate websocket when the device is not supported."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data=MOCK_WS_ENTRY)
|
||||
entry.add_to_hass(hass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue