Add return type to async tests without arguments (#87612)

This commit is contained in:
epenet 2023-02-07 10:26:56 +01:00 committed by GitHub
parent ea32a2ae63
commit aa00114c2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 117 additions and 117 deletions

View file

@ -4,7 +4,7 @@ from homeassistant.components.NEW_DOMAIN.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect NEW_NAME significant changes.""" """Detect NEW_NAME significant changes."""
attrs = {} attrs = {}
assert not async_check_significant_change(None, "on", attrs, "on", attrs) assert not async_check_significant_change(None, "on", attrs, "on", attrs)

View file

@ -36,7 +36,7 @@ async def test_validating_password_invalid_user(data, hass):
data.validate_login("non-existing", "pw") data.validate_login("non-existing", "pw")
async def test_not_allow_set_id(): async def test_not_allow_set_id() -> None:
"""Test we are not allowed to set an ID in config.""" """Test we are not allowed to set an ID in config."""
hass = Mock() hass = Mock()
with pytest.raises(vol.Invalid): with pytest.raises(vol.Invalid):

View file

@ -106,7 +106,7 @@ def test_parse_url_path():
assert indieauth._parse_url("http://ex.com").path == "/" assert indieauth._parse_url("http://ex.com").path == "/"
async def test_verify_redirect_uri(): async def test_verify_redirect_uri() -> None:
"""Test that we verify redirect uri correctly.""" """Test that we verify redirect uri correctly."""
assert await indieauth.verify_redirect_uri( assert await indieauth.verify_redirect_uri(
None, "http://ex.com", "http://ex.com/callback" None, "http://ex.com", "http://ex.com/callback"

View file

@ -4,7 +4,7 @@ from homeassistant.components.binary_sensor.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect Binary Sensor significant changes.""" """Detect Binary Sensor significant changes."""
old_attrs = {"attr_1": "value_1"} old_attrs = {"attr_1": "value_1"}
new_attrs = {"attr_1": "value_2"} new_attrs = {"attr_1": "value_2"}

View file

@ -61,7 +61,7 @@ async def test_create_auth_system_generated_user(hass, hass_ws_client):
assert result["error"]["code"] == "system_generated" assert result["error"]["code"] == "system_generated"
async def test_create_auth_user_already_credentials(): async def test_create_auth_user_already_credentials() -> None:
"""Test we can't create auth for user with pre-existing credentials.""" """Test we can't create auth for user with pre-existing credentials."""
# assert False # assert False

View file

@ -153,12 +153,12 @@ class _Data:
Data = _Data() Data = _Data()
async def test_v1_data(): async def test_v1_data() -> None:
"""Test for version 1 api based on message.""" """Test for version 1 api based on message."""
assert dialogflow.get_api_version(Data.v1) == 1 assert dialogflow.get_api_version(Data.v1) == 1
async def test_v2_data(): async def test_v2_data() -> None:
"""Test for version 2 api based on message.""" """Test for version 2 api based on message."""
assert dialogflow.get_api_version(Data.v2) == 2 assert dialogflow.get_api_version(Data.v2) == 2

View file

@ -5,14 +5,14 @@ import voluptuous as vol
from homeassistant.components.ecobee.util import ecobee_date, ecobee_time from homeassistant.components.ecobee.util import ecobee_date, ecobee_time
async def test_ecobee_date_with_valid_input(): async def test_ecobee_date_with_valid_input() -> None:
"""Test that the date function returns the expected result.""" """Test that the date function returns the expected result."""
test_input = "2019-09-27" test_input = "2019-09-27"
assert ecobee_date(test_input) == test_input assert ecobee_date(test_input) == test_input
async def test_ecobee_date_with_invalid_input(): async def test_ecobee_date_with_invalid_input() -> None:
"""Test that the date function raises the expected exception.""" """Test that the date function raises the expected exception."""
test_input = "20190927" test_input = "20190927"
@ -20,14 +20,14 @@ async def test_ecobee_date_with_invalid_input():
ecobee_date(test_input) ecobee_date(test_input)
async def test_ecobee_time_with_valid_input(): async def test_ecobee_time_with_valid_input() -> None:
"""Test that the time function returns the expected result.""" """Test that the time function returns the expected result."""
test_input = "20:55:15" test_input = "20:55:15"
assert ecobee_time(test_input) == test_input assert ecobee_time(test_input) == test_input
async def test_ecobee_time_with_invalid_input(): async def test_ecobee_time_with_invalid_input() -> None:
"""Test that the time function raises the expected exception.""" """Test that the time function raises the expected exception."""
test_input = "20:55" test_input = "20:55"

View file

@ -276,7 +276,7 @@ async def test_agent_user_id_storage(hass, hass_storage):
) )
async def test_agent_user_id_connect(): async def test_agent_user_id_connect() -> None:
"""Test the connection and disconnection of users.""" """Test the connection and disconnection of users."""
config = MockConfig() config = MockConfig()
store = config._store store = config._store

View file

@ -23,18 +23,18 @@ class FilterTest:
should_pass: bool should_pass: bool
async def test_datetime(): async def test_datetime() -> None:
"""Test datetime encoding.""" """Test datetime encoding."""
time = datetime(2019, 1, 13, 12, 30, 5) time = datetime(2019, 1, 13, 12, 30, 5)
assert victim().encode(time) == '"2019-01-13T12:30:05"' assert victim().encode(time) == '"2019-01-13T12:30:05"'
async def test_no_datetime(): async def test_no_datetime() -> None:
"""Test integer encoding.""" """Test integer encoding."""
assert victim().encode(42) == "42" assert victim().encode(42) == "42"
async def test_nested(): async def test_nested() -> None:
"""Test dictionary encoding.""" """Test dictionary encoding."""
assert victim().encode({"foo": "bar"}) == '{"foo": "bar"}' assert victim().encode({"foo": "bar"}) == '{"foo": "bar"}'

View file

@ -38,13 +38,13 @@ async def test_connect_error(hass, config):
assert result["errors"] == {CONF_IP_ADDRESS: "cannot_connect"} assert result["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
async def test_get_pin_from_discovery_hostname(): async def test_get_pin_from_discovery_hostname() -> None:
"""Test getting a device PIN from the zeroconf-discovered hostname.""" """Test getting a device PIN from the zeroconf-discovered hostname."""
pin = async_get_pin_from_discovery_hostname("GVC1-3456.local.") pin = async_get_pin_from_discovery_hostname("GVC1-3456.local.")
assert pin == "3456" assert pin == "3456"
async def test_get_pin_from_uid(): async def test_get_pin_from_uid() -> None:
"""Test getting a device PIN from its UID.""" """Test getting a device PIN from its UID."""
pin = async_get_pin_from_uid("ABCDEF123456") pin = async_get_pin_from_uid("ABCDEF123456")
assert pin == "3456" assert pin == "3456"

View file

@ -346,7 +346,7 @@ async def test_port_is_available_skips_existing_entries(hass):
async_find_next_available_port(hass, 65530) async_find_next_available_port(hass, 65530)
async def test_format_version(): async def test_format_version() -> None:
"""Test format_version method.""" """Test format_version method."""
assert format_version("soho+3.6.8+soho-release-rt120+10") == "3.6.8" assert format_version("soho+3.6.8+soho-release-rt120+10") == "3.6.8"
assert format_version("undefined-undefined-1.6.8") == "1.6.8" assert format_version("undefined-undefined-1.6.8") == "1.6.8"
@ -362,14 +362,14 @@ async def test_format_version():
assert format_version("unknown") is None assert format_version("unknown") is None
async def test_coerce_int(): async def test_coerce_int() -> None:
"""Test coerce_int method.""" """Test coerce_int method."""
assert coerce_int("1") == 1 assert coerce_int("1") == 1
assert coerce_int("") == 0 assert coerce_int("") == 0
assert coerce_int(0) == 0 assert coerce_int(0) == 0
async def test_accessory_friendly_name(): async def test_accessory_friendly_name() -> None:
"""Test we provide a helpful friendly name.""" """Test we provide a helpful friendly name."""
accessory = Mock() accessory = Mock()

View file

@ -88,7 +88,7 @@ async def test_hap_setup_works(hass):
assert hap.home is home assert hap.home is home
async def test_hap_setup_connection_error(): async def test_hap_setup_connection_error() -> None:
"""Test a failed accesspoint setup.""" """Test a failed accesspoint setup."""
hass = Mock() hass = Mock()
entry = Mock() entry = Mock()

View file

@ -42,7 +42,7 @@ async def test_invalid_json(caplog):
) )
async def test_nan_serialized_to_null(): async def test_nan_serialized_to_null() -> None:
"""Test nan serialized to null JSON.""" """Test nan serialized to null JSON."""
response = HomeAssistantView.json(float("NaN")) response = HomeAssistantView.json(float("NaN"))
assert json.loads(response.body.decode("utf-8")) is None assert json.loads(response.body.decode("utf-8")) is None

View file

@ -12,7 +12,7 @@ from . import MockLocation
from tests.common import MockConfigEntry, mock_registry from tests.common import MockConfigEntry, mock_registry
async def test_show_config_form(): async def test_show_config_form() -> None:
"""Test show configuration form.""" """Test show configuration form."""
hass = Mock() hass = Mock()
flow = config_flow.IpmaFlowHandler() flow = config_flow.IpmaFlowHandler()
@ -24,7 +24,7 @@ async def test_show_config_form():
assert result["step_id"] == "user" assert result["step_id"] == "user"
async def test_show_config_form_default_values(): async def test_show_config_form_default_values() -> None:
"""Test show configuration form.""" """Test show configuration form."""
hass = Mock() hass = Mock()
flow = config_flow.IpmaFlowHandler() flow = config_flow.IpmaFlowHandler()
@ -54,7 +54,7 @@ async def test_flow_with_home_location(hass):
assert result["step_id"] == "user" assert result["step_id"] == "user"
async def test_flow_show_form(): async def test_flow_show_form() -> None:
"""Test show form scenarios first time. """Test show form scenarios first time.
Test when the form should show when no configurations exists Test when the form should show when no configurations exists
@ -70,7 +70,7 @@ async def test_flow_show_form():
assert len(config_form.mock_calls) == 1 assert len(config_form.mock_calls) == 1
async def test_flow_entry_created_from_user_input(): async def test_flow_entry_created_from_user_input() -> None:
"""Test that create data from user input. """Test that create data from user input.
Test when the form should show when no configurations exists Test when the form should show when no configurations exists
@ -97,7 +97,7 @@ async def test_flow_entry_created_from_user_input():
assert not config_form.mock_calls assert not config_form.mock_calls
async def test_flow_entry_config_entry_already_exists(): async def test_flow_entry_config_entry_already_exists() -> None:
"""Test that create data from user input and config_entry already exists. """Test that create data from user input and config_entry already exists.
Test when the form should show when user puts existing name Test when the form should show when user puts existing name

View file

@ -10,7 +10,7 @@ from homeassistant.components.light.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect Light significant changes.""" """Detect Light significant changes."""
assert not async_check_significant_change(None, "on", {}, "on", {}) assert not async_check_significant_change(None, "on", {}, "on", {})
assert async_check_significant_change(None, "on", {}, "off", {}) assert async_check_significant_change(None, "on", {}, "off", {})

View file

@ -4,7 +4,7 @@ from homeassistant.components.lock.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect Lock significant changes.""" """Detect Lock significant changes."""
old_attrs = {"attr_1": "a"} old_attrs = {"attr_1": "a"}
new_attrs = {"attr_1": "b"} new_attrs = {"attr_1": "b"}

View file

@ -10,7 +10,7 @@ from homeassistant.components.media_source import const, models
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
async def test_is_media_source_id(): async def test_is_media_source_id() -> None:
"""Test media source validation.""" """Test media source validation."""
assert media_source.is_media_source_id(media_source.URI_SCHEME) assert media_source.is_media_source_id(media_source.URI_SCHEME)
assert media_source.is_media_source_id(f"{media_source.URI_SCHEME}domain") assert media_source.is_media_source_id(f"{media_source.URI_SCHEME}domain")
@ -20,7 +20,7 @@ async def test_is_media_source_id():
assert not media_source.is_media_source_id("test") assert not media_source.is_media_source_id("test")
async def test_generate_media_source_id(): async def test_generate_media_source_id() -> None:
"""Test identifier generation.""" """Test identifier generation."""
tests = [ tests = [
(None, None), (None, None),
@ -258,7 +258,7 @@ async def test_websocket_resolve_media(hass, hass_ws_client, filename):
assert msg["error"]["message"] == "test" assert msg["error"]["message"] == "test"
async def test_browse_resolve_without_setup(): async def test_browse_resolve_without_setup() -> None:
"""Test browse and resolve work without being setup.""" """Test browse and resolve work without being setup."""
with pytest.raises(BrowseError): with pytest.raises(BrowseError):
await media_source.async_browse_media(Mock(data={}), None) await media_source.async_browse_media(Mock(data={}), None)

View file

@ -3,7 +3,7 @@ from homeassistant.components.media_player import MediaClass, MediaType
from homeassistant.components.media_source import const, models from homeassistant.components.media_source import const, models
async def test_browse_media_as_dict(): async def test_browse_media_as_dict() -> None:
"""Test BrowseMediaSource conversion to media player item dict.""" """Test BrowseMediaSource conversion to media player item dict."""
base = models.BrowseMediaSource( base = models.BrowseMediaSource(
domain=const.DOMAIN, domain=const.DOMAIN,
@ -40,7 +40,7 @@ async def test_browse_media_as_dict():
assert item["children"][0]["media_class"] == MediaClass.MUSIC assert item["children"][0]["media_class"] == MediaClass.MUSIC
async def test_browse_media_parent_no_children(): async def test_browse_media_parent_no_children() -> None:
"""Test BrowseMediaSource conversion to media player item dict.""" """Test BrowseMediaSource conversion to media player item dict."""
base = models.BrowseMediaSource( base = models.BrowseMediaSource(
domain=const.DOMAIN, domain=const.DOMAIN,
@ -63,7 +63,7 @@ async def test_browse_media_parent_no_children():
assert item["children_media_class"] is None assert item["children_media_class"] is None
async def test_media_source_default_name(): async def test_media_source_default_name() -> None:
"""Test MediaSource uses domain as default name.""" """Test MediaSource uses domain as default name."""
source = models.MediaSource(const.DOMAIN) source = models.MediaSource(const.DOMAIN)
assert source.name == const.DOMAIN assert source.name == const.DOMAIN

View file

@ -153,7 +153,7 @@ async def test_minio_listen(hass, caplog, minio_client_event):
assert len(event.data["metadata"]) == 0 assert len(event.data["metadata"]) == 0
async def test_queue_listener(): async def test_queue_listener() -> None:
"""Tests QueueListener firing events on Home Assistant event bus.""" """Tests QueueListener firing events on Home Assistant event bus."""
hass = MagicMock() hass = MagicMock()

View file

@ -118,7 +118,7 @@ async def mock_modbus_with_pymodbus_fixture(hass, caplog, do_config, mock_pymodb
return mock_pymodbus return mock_pymodbus
async def test_number_validator(): async def test_number_validator() -> None:
"""Test number validator.""" """Test number validator."""
for value, value_type in ( for value, value_type in (

View file

@ -42,7 +42,7 @@ async def test_async_create_certificate_temp_files(
) )
async def test_reading_non_exitisting_certificate_file(): async def test_reading_non_exitisting_certificate_file() -> None:
"""Test reading a non existing certificate file.""" """Test reading a non existing certificate file."""
assert ( assert (
mqtt.util.migrate_certificate_file_to_content("/home/file_not_exists") is None mqtt.util.migrate_certificate_file_to_content("/home/file_not_exists") is None

View file

@ -5,7 +5,7 @@ from http import HTTPStatus
from homeassistant.components.nexia import util from homeassistant.components.nexia import util
async def test_is_invalid_auth_code(): async def test_is_invalid_auth_code() -> None:
"""Test for invalid auth.""" """Test for invalid auth."""
assert util.is_invalid_auth_code(HTTPStatus.UNAUTHORIZED) is True assert util.is_invalid_auth_code(HTTPStatus.UNAUTHORIZED) is True
@ -13,7 +13,7 @@ async def test_is_invalid_auth_code():
assert util.is_invalid_auth_code(HTTPStatus.NOT_FOUND) is False assert util.is_invalid_auth_code(HTTPStatus.NOT_FOUND) is False
async def test_percent_conv(): async def test_percent_conv() -> None:
"""Test percentage conversion.""" """Test percentage conversion."""
assert util.percent_conv(0.12) == 12.0 assert util.percent_conv(0.12) == 12.0

View file

@ -37,7 +37,7 @@ async def test_setup_views_if_not_onboarded(hass):
assert not onboarding.async_is_onboarded(hass) assert not onboarding.async_is_onboarded(hass)
async def test_is_onboarded(): async def test_is_onboarded() -> None:
"""Test the is onboarded function.""" """Test the is onboarded function."""
hass = Mock() hass = Mock()
hass.data = {} hass.data = {}
@ -51,7 +51,7 @@ async def test_is_onboarded():
assert not onboarding.async_is_onboarded(hass) assert not onboarding.async_is_onboarded(hass)
async def test_is_user_onboarded(): async def test_is_user_onboarded() -> None:
"""Test the is onboarded function.""" """Test the is onboarded function."""
hass = Mock() hass = Mock()
hass.data = {} hass.data = {}

View file

@ -4,7 +4,7 @@ from homeassistant.components.person.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect Person significant changes and ensure that attribute changes do not trigger a significant change.""" """Detect Person significant changes and ensure that attribute changes do not trigger a significant change."""
old_attrs = {"source": "device_tracker.wifi_device"} old_attrs = {"source": "device_tracker.wifi_device"}
new_attrs = {"source": "device_tracker.gps_device"} new_attrs = {"source": "device_tracker.gps_device"}

View file

@ -227,7 +227,7 @@ def test_states_from_native_invalid_entity_id():
assert state.entity_id == "test.invalid__id" assert state.entity_id == "test.invalid__id"
async def test_process_timestamp(): async def test_process_timestamp() -> None:
"""Test processing time stamp to UTC.""" """Test processing time stamp to UTC."""
datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC) datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC)
datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0) datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0)
@ -256,7 +256,7 @@ async def test_process_timestamp():
assert process_timestamp(None) is None assert process_timestamp(None) is None
async def test_process_timestamp_to_utc_isoformat(): async def test_process_timestamp_to_utc_isoformat() -> None:
"""Test processing time stamp to UTC isoformat.""" """Test processing time stamp to UTC isoformat."""
datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC) datetime_with_tzinfo = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC)
datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0) datetime_without_tzinfo = datetime(2016, 7, 9, 11, 0, 0)
@ -292,7 +292,7 @@ async def test_process_timestamp_to_utc_isoformat():
assert process_timestamp_to_utc_isoformat(None) is None assert process_timestamp_to_utc_isoformat(None) is None
async def test_event_to_db_model(): async def test_event_to_db_model() -> None:
"""Test we can round trip Event conversion.""" """Test we can round trip Event conversion."""
event = ha.Event( event = ha.Event(
"state_changed", {"some": "attr"}, ha.EventOrigin.local, dt_util.utcnow() "state_changed", {"some": "attr"}, ha.EventOrigin.local, dt_util.utcnow()

View file

@ -9,7 +9,7 @@ from homeassistant.components.recorder.const import DB_WORKER_PREFIX
from homeassistant.components.recorder.pool import RecorderPool from homeassistant.components.recorder.pool import RecorderPool
async def test_recorder_pool_called_from_event_loop(): async def test_recorder_pool_called_from_event_loop() -> None:
"""Test we raise an exception when calling from the event loop.""" """Test we raise an exception when calling from the event loop."""
engine = create_engine("sqlite://", poolclass=RecorderPool) engine = create_engine("sqlite://", poolclass=RecorderPool)
with pytest.raises(RuntimeError): with pytest.raises(RuntimeError):

View file

@ -60,7 +60,7 @@ from homeassistant.util import dt
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
async def test_climate_find_valid_targets(): async def test_climate_find_valid_targets() -> None:
"""Test function to return temperature from valid targets.""" """Test function to return temperature from valid targets."""
valid_targets = [10, 16, 17, 18, 19, 20] valid_targets = [10, 16, 17, 18, 19, 20]

View file

@ -151,7 +151,7 @@ async def test_get_block_device_sleep_period(settings, sleep_period):
@freeze_time("2019-01-10 18:43:00+00:00") @freeze_time("2019-01-10 18:43:00+00:00")
async def test_get_device_uptime(): async def test_get_device_uptime() -> None:
"""Test block test get device uptime.""" """Test block test get device uptime."""
assert get_device_uptime( assert get_device_uptime(
55, dt.as_utc(dt.parse_datetime("2019-01-10 18:42:00+00:00")) 55, dt.as_utc(dt.parse_datetime("2019-01-10 18:42:00+00:00"))

View file

@ -38,7 +38,7 @@ def filter_log_records(caplog: LogCaptureFixture) -> list[logging.LogRecord]:
] ]
async def test_message_includes_default_emoji(): async def test_message_includes_default_emoji() -> None:
"""Tests that default icon is used when no message icon is given.""" """Tests that default icon is used when no message icon is given."""
mock_client = Mock() mock_client = Mock()
mock_client.chat_postMessage = AsyncMock() mock_client.chat_postMessage = AsyncMock()
@ -55,7 +55,7 @@ async def test_message_includes_default_emoji():
assert kwargs["icon_emoji"] == expected_icon assert kwargs["icon_emoji"] == expected_icon
async def test_message_emoji_overrides_default(): async def test_message_emoji_overrides_default() -> None:
"""Tests that overriding the default icon emoji when sending a message works.""" """Tests that overriding the default icon emoji when sending a message works."""
mock_client = Mock() mock_client = Mock()
mock_client.chat_postMessage = AsyncMock() mock_client.chat_postMessage = AsyncMock()
@ -72,7 +72,7 @@ async def test_message_emoji_overrides_default():
assert kwargs["icon_emoji"] == expected_icon assert kwargs["icon_emoji"] == expected_icon
async def test_message_includes_default_icon_url(): async def test_message_includes_default_icon_url() -> None:
"""Tests that overriding the default icon url when sending a message works.""" """Tests that overriding the default icon url when sending a message works."""
mock_client = Mock() mock_client = Mock()
mock_client.chat_postMessage = AsyncMock() mock_client.chat_postMessage = AsyncMock()
@ -89,7 +89,7 @@ async def test_message_includes_default_icon_url():
assert kwargs["icon_url"] == expected_icon assert kwargs["icon_url"] == expected_icon
async def test_message_icon_url_overrides_default(): async def test_message_icon_url_overrides_default() -> None:
"""Tests that overriding the default icon url when sending a message works.""" """Tests that overriding the default icon url when sending a message works."""
mock_client = Mock() mock_client = Mock()
mock_client.chat_postMessage = AsyncMock() mock_client.chat_postMessage = AsyncMock()

View file

@ -20,7 +20,7 @@ from homeassistant.helpers.entity import EntityCategory
from .conftest import setup_platform from .conftest import setup_platform
async def test_mapping_integrity(): async def test_mapping_integrity() -> None:
"""Test ensures the map dicts have proper integrity.""" """Test ensures the map dicts have proper integrity."""
# Ensure every CAPABILITY_TO_ATTRIB key is in CAPABILITIES # Ensure every CAPABILITY_TO_ATTRIB key is in CAPABILITIES
# Ensure every CAPABILITY_TO_ATTRIB value is in ATTRIB_TO_CLASS keys # Ensure every CAPABILITY_TO_ATTRIB value is in ATTRIB_TO_CLASS keys

View file

@ -27,7 +27,7 @@ from homeassistant.helpers.entity import EntityCategory
from .conftest import setup_platform from .conftest import setup_platform
async def test_mapping_integrity(): async def test_mapping_integrity() -> None:
"""Test ensures the map dicts have proper integrity.""" """Test ensures the map dicts have proper integrity."""
for capability, maps in sensor.CAPABILITY_TO_SENSORS.items(): for capability, maps in sensor.CAPABILITY_TO_SENSORS.items():
assert capability in CAPABILITIES, capability assert capability in CAPABILITIES, capability

View file

@ -6,7 +6,7 @@ import pytest
from homeassistant.components.sonos.helpers import hostname_to_uid from homeassistant.components.sonos.helpers import hostname_to_uid
async def test_uid_to_hostname(): async def test_uid_to_hostname() -> None:
"""Test we can convert a hostname to a uid.""" """Test we can convert a hostname to a uid."""
assert hostname_to_uid("Sonos-347E5C0CF1E3.local.") == "RINCON_347E5C0CF1E301400" assert hostname_to_uid("Sonos-347E5C0CF1E3.local.") == "RINCON_347E5C0CF1E301400"
assert hostname_to_uid("sonos5CAAFDE47AC8.local.") == "RINCON_5CAAFDE47AC801400" assert hostname_to_uid("sonos5CAAFDE47AC8.local.") == "RINCON_5CAAFDE47AC801400"

View file

@ -4,7 +4,7 @@ from homeassistant.components.switch.significant_change import (
) )
async def test_significant_change(): async def test_significant_change() -> None:
"""Detect Switch significant change.""" """Detect Switch significant change."""
attrs = {} attrs = {}
assert not async_check_significant_change(None, "on", attrs, "on", attrs) assert not async_check_significant_change(None, "on", attrs, "on", attrs)

View file

@ -112,7 +112,7 @@ async def test_device_diagnostics_error(hass, integration):
await async_get_device_diagnostics(hass, integration, device) await async_get_device_diagnostics(hass, integration, device)
async def test_empty_zwave_value_matcher(): async def test_empty_zwave_value_matcher() -> None:
"""Test empty ZwaveValueMatcher is invalid.""" """Test empty ZwaveValueMatcher is invalid."""
with pytest.raises(ValueError): with pytest.raises(ValueError):
ZwaveValueMatcher() ZwaveValueMatcher()

View file

@ -112,7 +112,7 @@ def test_id_manager():
assert id_manager.generate_id("bla") == "bla" assert id_manager.generate_id("bla") == "bla"
async def test_observable_collection(): async def test_observable_collection() -> None:
"""Test observerable collection.""" """Test observerable collection."""
coll = collection.ObservableCollection(_LOGGER) coll = collection.ObservableCollection(_LOGGER)
assert coll.async_items() == [] assert coll.async_items() == []
@ -127,7 +127,7 @@ async def test_observable_collection():
assert changes[0] == ("mock_type", "mock_id", {"mock": "item"}) assert changes[0] == ("mock_type", "mock_id", {"mock": "item"})
async def test_yaml_collection(): async def test_yaml_collection() -> None:
"""Test a YAML collection.""" """Test a YAML collection."""
id_manager = collection.IDManager() id_manager = collection.IDManager()
coll = collection.YamlCollection(_LOGGER, id_manager) coll = collection.YamlCollection(_LOGGER, id_manager)
@ -171,7 +171,7 @@ async def test_yaml_collection():
) )
async def test_yaml_collection_skipping_duplicate_ids(): async def test_yaml_collection_skipping_duplicate_ids() -> None:
"""Test YAML collection skipping duplicate IDs.""" """Test YAML collection skipping duplicate IDs."""
id_manager = collection.IDManager() id_manager = collection.IDManager()
id_manager.add_collection({"existing": True}) id_manager.add_collection({"existing": True})

View file

@ -1934,7 +1934,7 @@ async def test_multiple_zones(hass):
assert not test(hass) assert not test(hass)
async def test_extract_entities(): async def test_extract_entities() -> None:
"""Test extracting entities.""" """Test extracting entities."""
assert condition.async_extract_entities( assert condition.async_extract_entities(
{ {
@ -2007,7 +2007,7 @@ async def test_extract_entities():
} }
async def test_extract_devices(): async def test_extract_devices() -> None:
"""Test extracting devices.""" """Test extracting devices."""
assert condition.async_extract_devices( assert condition.async_extract_devices(
{ {

View file

@ -876,7 +876,7 @@ def test_entity_category_schema_error(value):
schema(value) schema(value)
async def test_entity_description_fallback(): async def test_entity_description_fallback() -> None:
"""Test entity description has same defaults as entity.""" """Test entity description has same defaults as entity."""
ent = entity.Entity() ent = entity.Entity()
ent_with_description = entity.Entity() ent_with_description = entity.Entity()
@ -955,7 +955,7 @@ async def test_translation_key(hass):
assert mock_entity2.translation_key == "from_entity_description" assert mock_entity2.translation_key == "from_entity_description"
async def test_repr_using_stringify_state(): async def test_repr_using_stringify_state() -> None:
"""Test that repr uses stringify state.""" """Test that repr uses stringify state."""
class MyEntity(MockEntity): class MyEntity(MockEntity):

View file

@ -4,7 +4,7 @@ import pytest
from homeassistant.helpers import config_validation as cv, template from homeassistant.helpers import config_validation as cv, template
async def test_static_vars(): async def test_static_vars() -> None:
"""Test static vars.""" """Test static vars."""
orig = {"hello": "world"} orig = {"hello": "world"}
var = cv.SCRIPT_VARIABLES_SCHEMA(orig) var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
@ -13,7 +13,7 @@ async def test_static_vars():
assert rendered == orig assert rendered == orig
async def test_static_vars_run_args(): async def test_static_vars_run_args() -> None:
"""Test static vars.""" """Test static vars."""
orig = {"hello": "world"} orig = {"hello": "world"}
orig_copy = dict(orig) orig_copy = dict(orig)
@ -24,7 +24,7 @@ async def test_static_vars_run_args():
assert orig == orig_copy assert orig == orig_copy
async def test_static_vars_no_default(): async def test_static_vars_no_default() -> None:
"""Test static vars.""" """Test static vars."""
orig = {"hello": "world"} orig = {"hello": "world"}
var = cv.SCRIPT_VARIABLES_SCHEMA(orig) var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
@ -33,7 +33,7 @@ async def test_static_vars_no_default():
assert rendered == orig assert rendered == orig
async def test_static_vars_run_args_no_default(): async def test_static_vars_run_args_no_default() -> None:
"""Test static vars.""" """Test static vars."""
orig = {"hello": "world"} orig = {"hello": "world"}
orig_copy = dict(orig) orig_copy = dict(orig)

View file

@ -975,7 +975,7 @@ async def test_serviceregistry_callback_service_raise_exception(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
async def test_config_defaults(): async def test_config_defaults() -> None:
"""Test config defaults.""" """Test config defaults."""
hass = Mock() hass = Mock()
config = ha.Config(hass) config = ha.Config(hass)
@ -1003,21 +1003,21 @@ async def test_config_defaults():
assert config.language == "en" assert config.language == "en"
async def test_config_path_with_file(): async def test_config_path_with_file() -> None:
"""Test get_config_path method.""" """Test get_config_path method."""
config = ha.Config(None) config = ha.Config(None)
config.config_dir = "/test/ha-config" config.config_dir = "/test/ha-config"
assert config.path("test.conf") == "/test/ha-config/test.conf" assert config.path("test.conf") == "/test/ha-config/test.conf"
async def test_config_path_with_dir_and_file(): async def test_config_path_with_dir_and_file() -> None:
"""Test get_config_path method.""" """Test get_config_path method."""
config = ha.Config(None) config = ha.Config(None)
config.config_dir = "/test/ha-config" config.config_dir = "/test/ha-config"
assert config.path("dir", "test.conf") == "/test/ha-config/dir/test.conf" assert config.path("dir", "test.conf") == "/test/ha-config/dir/test.conf"
async def test_config_as_dict(): async def test_config_as_dict() -> None:
"""Test as dict.""" """Test as dict."""
config = ha.Config(None) config = ha.Config(None)
config.config_dir = "/test/ha-config" config.config_dir = "/test/ha-config"
@ -1049,7 +1049,7 @@ async def test_config_as_dict():
assert expected == config.as_dict() assert expected == config.as_dict()
async def test_config_is_allowed_path(): async def test_config_is_allowed_path() -> None:
"""Test is_allowed_path method.""" """Test is_allowed_path method."""
config = ha.Config(None) config = ha.Config(None)
with TemporaryDirectory() as tmp_dir: with TemporaryDirectory() as tmp_dir:
@ -1081,7 +1081,7 @@ async def test_config_is_allowed_path():
config.is_allowed_path(None) config.is_allowed_path(None)
async def test_config_is_allowed_external_url(): async def test_config_is_allowed_external_url() -> None:
"""Test is_allowed_external_url method.""" """Test is_allowed_external_url method."""
config = ha.Config(None) config = ha.Config(None)
config.allowlist_external_urls = [ config.allowlist_external_urls = [
@ -1507,7 +1507,7 @@ async def test_async_entity_ids_count(hass):
assert hass.states.async_entity_ids_count("light") == 3 assert hass.states.async_entity_ids_count("light") == 3
async def test_hassjob_forbid_coroutine(): async def test_hassjob_forbid_coroutine() -> None:
"""Test hassjob forbids coroutines.""" """Test hassjob forbids coroutines."""
async def bla(): async def bla():

View file

@ -15,7 +15,7 @@ SUPERVISOR_HARD_TIMEOUT = 220
TIMEOUT_SAFETY_MARGIN = 10 TIMEOUT_SAFETY_MARGIN = 10
async def test_cumulative_shutdown_timeout_less_than_supervisor(): async def test_cumulative_shutdown_timeout_less_than_supervisor() -> None:
"""Verify the cumulative shutdown timeout is at least 10s less than the supervisor.""" """Verify the cumulative shutdown timeout is at least 10s less than the supervisor."""
assert ( assert (
core.STAGE_1_SHUTDOWN_TIMEOUT core.STAGE_1_SHUTDOWN_TIMEOUT

View file

@ -4,7 +4,7 @@ import pytest
from .aiohttp import AiohttpClientMocker from .aiohttp import AiohttpClientMocker
async def test_matching_url(): async def test_matching_url() -> None:
"""Test we can match urls.""" """Test we can match urls."""
mocker = AiohttpClientMocker() mocker = AiohttpClientMocker()
mocker.get("http://example.com") mocker.get("http://example.com")

View file

@ -4,21 +4,21 @@ from aiohttp import web
from homeassistant.util import aiohttp from homeassistant.util import aiohttp
async def test_request_json(): async def test_request_json() -> None:
"""Test a JSON request.""" """Test a JSON request."""
request = aiohttp.MockRequest(b'{"hello": 2}', mock_source="test") request = aiohttp.MockRequest(b'{"hello": 2}', mock_source="test")
assert request.status == 200 assert request.status == 200
assert await request.json() == {"hello": 2} assert await request.json() == {"hello": 2}
async def test_request_text(): async def test_request_text() -> None:
"""Test a JSON request.""" """Test a JSON request."""
request = aiohttp.MockRequest(b"hello", status=201, mock_source="test") request = aiohttp.MockRequest(b"hello", status=201, mock_source="test")
assert request.status == 201 assert request.status == 201
assert await request.text() == "hello" assert await request.text() == "hello"
async def test_request_post_query(): async def test_request_post_query() -> None:
"""Test a JSON request.""" """Test a JSON request."""
request = aiohttp.MockRequest( request = aiohttp.MockRequest(
b"hello=2&post=true", query_string="get=true", method="POST", mock_source="test" b"hello=2&post=true", query_string="get=true", method="POST", mock_source="test"

View file

@ -75,7 +75,7 @@ def banned_function():
"""Mock banned function.""" """Mock banned function."""
async def test_check_loop_async(): async def test_check_loop_async() -> None:
"""Test check_loop detects when called from event loop without integration context.""" """Test check_loop detects when called from event loop without integration context."""
with pytest.raises(RuntimeError): with pytest.raises(RuntimeError):
hasync.check_loop(banned_function) hasync.check_loop(banned_function)
@ -217,7 +217,7 @@ async def test_protect_loop_debugger_sleep(caplog):
assert "Detected blocking call inside the event loop" not in caplog.text assert "Detected blocking call inside the event loop" not in caplog.text
async def test_gather_with_concurrency(): async def test_gather_with_concurrency() -> None:
"""Test gather_with_concurrency limits the number of running tasks.""" """Test gather_with_concurrency limits the number of running tasks."""
runs = 0 runs = 0

View file

@ -214,7 +214,7 @@ def test_get_random_string(mock_random):
assert util.get_random_string(length=3) == "ABC" assert util.get_random_string(length=3) == "ABC"
async def test_throttle_async(): async def test_throttle_async() -> None:
"""Test Throttle decorator with async method.""" """Test Throttle decorator with async method."""
@util.Throttle(timedelta(seconds=2)) @util.Throttle(timedelta(seconds=2))

View file

@ -24,7 +24,7 @@ def test_sensitive_data_filter():
assert sensitive_record.msg == "******* log" assert sensitive_record.msg == "******* log"
async def test_logging_with_queue_handler(): async def test_logging_with_queue_handler() -> None:
"""Test logging with HomeAssistantQueueHandler.""" """Test logging with HomeAssistantQueueHandler."""
simple_queue = queue.SimpleQueue() # type: ignore simple_queue = queue.SimpleQueue() # type: ignore

View file

@ -28,7 +28,7 @@ SMALL_ORDERED_LIST = [SPEED_1, SPEED_2, SPEED_3, SPEED_4]
LARGE_ORDERED_LIST = [SPEED_1, SPEED_2, SPEED_3, SPEED_4, SPEED_5, SPEED_6, SPEED_7] LARGE_ORDERED_LIST = [SPEED_1, SPEED_2, SPEED_3, SPEED_4, SPEED_5, SPEED_6, SPEED_7]
async def test_ordered_list_item_to_percentage(): async def test_ordered_list_item_to_percentage() -> None:
"""Test percentage of an item in an ordered list.""" """Test percentage of an item in an ordered list."""
assert ordered_list_item_to_percentage(LEGACY_ORDERED_LIST, SPEED_LOW) == 33 assert ordered_list_item_to_percentage(LEGACY_ORDERED_LIST, SPEED_LOW) == 33
@ -52,7 +52,7 @@ async def test_ordered_list_item_to_percentage():
assert ordered_list_item_to_percentage([], SPEED_1) assert ordered_list_item_to_percentage([], SPEED_1)
async def test_percentage_to_ordered_list_item(): async def test_percentage_to_ordered_list_item() -> None:
"""Test item that most closely matches the percentage in an ordered list.""" """Test item that most closely matches the percentage in an ordered list."""
assert percentage_to_ordered_list_item(SMALL_ORDERED_LIST, 1) == SPEED_1 assert percentage_to_ordered_list_item(SMALL_ORDERED_LIST, 1) == SPEED_1
@ -102,7 +102,7 @@ async def test_percentage_to_ordered_list_item():
assert percentage_to_ordered_list_item([], 100) assert percentage_to_ordered_list_item([], 100)
async def test_ranged_value_to_percentage_large(): async def test_ranged_value_to_percentage_large() -> None:
"""Test a large range of low and high values convert a single value to a percentage.""" """Test a large range of low and high values convert a single value to a percentage."""
range = (1, 255) range = (1, 255)
@ -112,7 +112,7 @@ async def test_ranged_value_to_percentage_large():
assert ranged_value_to_percentage(range, 1) == 0 assert ranged_value_to_percentage(range, 1) == 0
async def test_percentage_to_ranged_value_large(): async def test_percentage_to_ranged_value_large() -> None:
"""Test a large range of low and high values convert a percentage to a single value.""" """Test a large range of low and high values convert a percentage to a single value."""
range = (1, 255) range = (1, 255)
@ -125,7 +125,7 @@ async def test_percentage_to_ranged_value_large():
assert math.ceil(percentage_to_ranged_value(range, 4)) == 11 assert math.ceil(percentage_to_ranged_value(range, 4)) == 11
async def test_ranged_value_to_percentage_small(): async def test_ranged_value_to_percentage_small() -> None:
"""Test a small range of low and high values convert a single value to a percentage.""" """Test a small range of low and high values convert a single value to a percentage."""
range = (1, 6) range = (1, 6)
@ -137,7 +137,7 @@ async def test_ranged_value_to_percentage_small():
assert ranged_value_to_percentage(range, 6) == 100 assert ranged_value_to_percentage(range, 6) == 100
async def test_percentage_to_ranged_value_small(): async def test_percentage_to_ranged_value_small() -> None:
"""Test a small range of low and high values convert a percentage to a single value.""" """Test a small range of low and high values convert a percentage to a single value."""
range = (1, 6) range = (1, 6)
@ -149,7 +149,7 @@ async def test_percentage_to_ranged_value_small():
assert math.ceil(percentage_to_ranged_value(range, 100)) == 6 assert math.ceil(percentage_to_ranged_value(range, 100)) == 6
async def test_ranged_value_to_percentage_starting_at_one(): async def test_ranged_value_to_percentage_starting_at_one() -> None:
"""Test a range that starts with 1.""" """Test a range that starts with 1."""
range = (1, 4) range = (1, 4)
@ -159,7 +159,7 @@ async def test_ranged_value_to_percentage_starting_at_one():
assert ranged_value_to_percentage(range, 4) == 100 assert ranged_value_to_percentage(range, 4) == 100
async def test_ranged_value_to_percentage_starting_high(): async def test_ranged_value_to_percentage_starting_high() -> None:
"""Test a range that does not start with 1.""" """Test a range that does not start with 1."""
range = (101, 255) range = (101, 255)
@ -170,7 +170,7 @@ async def test_ranged_value_to_percentage_starting_high():
assert ranged_value_to_percentage(range, 255) == 100 assert ranged_value_to_percentage(range, 255) == 100
async def test_ranged_value_to_percentage_starting_zero(): async def test_ranged_value_to_percentage_starting_zero() -> None:
"""Test a range that starts with 0.""" """Test a range that starts with 0."""
range = (0, 3) range = (0, 3)

View file

@ -8,7 +8,7 @@ import pytest
from homeassistant.util import process from homeassistant.util import process
async def test_kill_process(): async def test_kill_process() -> None:
"""Test killing a process.""" """Test killing a process."""
sleeper = subprocess.Popen( sleeper = subprocess.Popen(
"sleep 1000", "sleep 1000",

View file

@ -57,7 +57,7 @@ class _EmptyClass:
"""An empty class.""" """An empty class."""
async def test_deadlock_safe_shutdown_no_threads(): async def test_deadlock_safe_shutdown_no_threads() -> None:
"""Test we can shutdown without deadlock without any threads to join.""" """Test we can shutdown without deadlock without any threads to join."""
dead_thread_mock = Mock( dead_thread_mock = Mock(
@ -78,7 +78,7 @@ async def test_deadlock_safe_shutdown_no_threads():
assert not daemon_thread_mock.join.called assert not daemon_thread_mock.join.called
async def test_deadlock_safe_shutdown(): async def test_deadlock_safe_shutdown() -> None:
"""Test we can shutdown without deadlock.""" """Test we can shutdown without deadlock."""
normal_thread_mock = Mock( normal_thread_mock = Mock(

View file

@ -8,7 +8,7 @@ import pytest
from homeassistant.util.timeout import TimeoutManager from homeassistant.util.timeout import TimeoutManager
async def test_simple_global_timeout(): async def test_simple_global_timeout() -> None:
"""Test a simple global timeout.""" """Test a simple global timeout."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -26,7 +26,7 @@ async def test_simple_global_timeout_with_executor_job(hass):
await hass.async_add_executor_job(lambda: time.sleep(0.2)) await hass.async_add_executor_job(lambda: time.sleep(0.2))
async def test_simple_global_timeout_freeze(): async def test_simple_global_timeout_freeze() -> None:
"""Test a simple global timeout freeze.""" """Test a simple global timeout freeze."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -130,7 +130,7 @@ async def test_simple_global_timeout_freeze_with_executor_job(hass):
await hass.async_add_executor_job(lambda: time.sleep(0.3)) await hass.async_add_executor_job(lambda: time.sleep(0.3))
async def test_simple_global_timeout_freeze_reset(): async def test_simple_global_timeout_freeze_reset() -> None:
"""Test a simple global timeout freeze reset.""" """Test a simple global timeout freeze reset."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -141,7 +141,7 @@ async def test_simple_global_timeout_freeze_reset():
await asyncio.sleep(0.2) await asyncio.sleep(0.2)
async def test_simple_zone_timeout(): async def test_simple_zone_timeout() -> None:
"""Test a simple zone timeout.""" """Test a simple zone timeout."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -150,7 +150,7 @@ async def test_simple_zone_timeout():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_multiple_zone_timeout(): async def test_multiple_zone_timeout() -> None:
"""Test a simple zone timeout.""" """Test a simple zone timeout."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -160,7 +160,7 @@ async def test_multiple_zone_timeout():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_different_zone_timeout(): async def test_different_zone_timeout() -> None:
"""Test a simple zone timeout.""" """Test a simple zone timeout."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -170,7 +170,7 @@ async def test_different_zone_timeout():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_simple_zone_timeout_freeze(): async def test_simple_zone_timeout_freeze() -> None:
"""Test a simple zone timeout freeze.""" """Test a simple zone timeout freeze."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -179,7 +179,7 @@ async def test_simple_zone_timeout_freeze():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_simple_zone_timeout_freeze_without_timeout(): async def test_simple_zone_timeout_freeze_without_timeout() -> None:
"""Test a simple zone timeout freeze on a zone that does not have a timeout set.""" """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -188,7 +188,7 @@ async def test_simple_zone_timeout_freeze_without_timeout():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_simple_zone_timeout_freeze_reset(): async def test_simple_zone_timeout_freeze_reset() -> None:
"""Test a simple zone timeout freeze reset.""" """Test a simple zone timeout freeze reset."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -199,7 +199,7 @@ async def test_simple_zone_timeout_freeze_reset():
await asyncio.sleep(0.2, "test") await asyncio.sleep(0.2, "test")
async def test_mix_zone_timeout_freeze_and_global_freeze(): async def test_mix_zone_timeout_freeze_and_global_freeze() -> None:
"""Test a mix zone timeout freeze and global freeze.""" """Test a mix zone timeout freeze and global freeze."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -209,7 +209,7 @@ async def test_mix_zone_timeout_freeze_and_global_freeze():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_mix_global_and_zone_timeout_freeze_(): async def test_mix_global_and_zone_timeout_freeze_() -> None:
"""Test a mix zone timeout freeze and global freeze.""" """Test a mix zone timeout freeze and global freeze."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -219,7 +219,7 @@ async def test_mix_global_and_zone_timeout_freeze_():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_mix_zone_timeout_freeze(): async def test_mix_zone_timeout_freeze() -> None:
"""Test a mix zone timeout global freeze.""" """Test a mix zone timeout global freeze."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -228,7 +228,7 @@ async def test_mix_zone_timeout_freeze():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_mix_zone_timeout(): async def test_mix_zone_timeout() -> None:
"""Test a mix zone timeout global.""" """Test a mix zone timeout global."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -238,7 +238,7 @@ async def test_mix_zone_timeout():
await asyncio.sleep(0.4) await asyncio.sleep(0.4)
async def test_mix_zone_timeout_trigger_global(): async def test_mix_zone_timeout_trigger_global() -> None:
"""Test a mix zone timeout global with trigger it.""" """Test a mix zone timeout global with trigger it."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -251,7 +251,7 @@ async def test_mix_zone_timeout_trigger_global():
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_mix_zone_timeout_trigger_global_cool_down(): async def test_mix_zone_timeout_trigger_global_cool_down() -> None:
"""Test a mix zone timeout global with trigger it with cool_down.""" """Test a mix zone timeout global with trigger it with cool_down."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -290,7 +290,7 @@ async def test_simple_zone_timeout_freeze_without_timeout_cleanup2(hass):
await asyncio.sleep(0.3) await asyncio.sleep(0.3)
async def test_simple_zone_timeout_freeze_without_timeout_exeption(): async def test_simple_zone_timeout_freeze_without_timeout_exeption() -> None:
"""Test a simple zone timeout freeze on a zone that does not have a timeout set.""" """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
timeout = TimeoutManager() timeout = TimeoutManager()
@ -303,7 +303,7 @@ async def test_simple_zone_timeout_freeze_without_timeout_exeption():
await asyncio.sleep(0.4) await asyncio.sleep(0.4)
async def test_simple_zone_timeout_zone_with_timeout_exeption(): async def test_simple_zone_timeout_zone_with_timeout_exeption() -> None:
"""Test a simple zone timeout freeze on a zone that does not have a timeout set.""" """Test a simple zone timeout freeze on a zone that does not have a timeout set."""
timeout = TimeoutManager() timeout = TimeoutManager()

View file

@ -5,12 +5,12 @@ import uuid
import homeassistant.util.ulid as ulid_util import homeassistant.util.ulid as ulid_util
async def test_ulid_util_uuid_hex(): async def test_ulid_util_uuid_hex() -> None:
"""Verify we can generate a ulid in hex.""" """Verify we can generate a ulid in hex."""
assert len(ulid_util.ulid_hex()) == 32 assert len(ulid_util.ulid_hex()) == 32
assert uuid.UUID(ulid_util.ulid_hex()) assert uuid.UUID(ulid_util.ulid_hex())
async def test_ulid_util_uuid(): async def test_ulid_util_uuid() -> None:
"""Verify we can generate a ulid.""" """Verify we can generate a ulid."""
assert len(ulid_util.ulid()) == 26 assert len(ulid_util.ulid()) == 26

View file

@ -5,7 +5,7 @@ import uuid
import homeassistant.util.uuid as uuid_util import homeassistant.util.uuid as uuid_util
async def test_uuid_util_random_uuid_hex(): async def test_uuid_util_random_uuid_hex() -> None:
"""Verify we can generate a random uuid.""" """Verify we can generate a random uuid."""
assert len(uuid_util.random_uuid_hex()) == 32 assert len(uuid_util.random_uuid_hex()) == 32
assert uuid.UUID(uuid_util.random_uuid_hex()) assert uuid.UUID(uuid_util.random_uuid_hex())