Add return type to tests without arguments (#87613)
* Add return type to tests without arguments * Black * Cancel fixture amends
This commit is contained in:
parent
fb4c0b4b7a
commit
4142f0d15d
99 changed files with 473 additions and 459 deletions
|
@ -13,14 +13,14 @@ from homeassistant.helpers.entity_registry import RegistryEntry
|
|||
from tests.common import mock_device_registry, mock_registry
|
||||
|
||||
|
||||
def test_entities_none():
|
||||
def test_entities_none() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = None
|
||||
compiled = compile_entities(policy, None)
|
||||
assert compiled("light.kitchen", "read") is False
|
||||
|
||||
|
||||
def test_entities_empty():
|
||||
def test_entities_empty() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -28,14 +28,14 @@ def test_entities_empty():
|
|||
assert compiled("light.kitchen", "read") is False
|
||||
|
||||
|
||||
def test_entities_false():
|
||||
def test_entities_false() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = False
|
||||
with pytest.raises(vol.Invalid):
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
||||
|
||||
def test_entities_true():
|
||||
def test_entities_true() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = True
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -43,7 +43,7 @@ def test_entities_true():
|
|||
assert compiled("light.kitchen", "read") is True
|
||||
|
||||
|
||||
def test_entities_domains_true():
|
||||
def test_entities_domains_true() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"domains": True}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -51,7 +51,7 @@ def test_entities_domains_true():
|
|||
assert compiled("light.kitchen", "read") is True
|
||||
|
||||
|
||||
def test_entities_domains_domain_true():
|
||||
def test_entities_domains_domain_true() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"domains": {"light": True}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -60,14 +60,14 @@ def test_entities_domains_domain_true():
|
|||
assert compiled("switch.kitchen", "read") is False
|
||||
|
||||
|
||||
def test_entities_domains_domain_false():
|
||||
def test_entities_domains_domain_false() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"domains": {"light": False}}
|
||||
with pytest.raises(vol.Invalid):
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
||||
|
||||
def test_entities_entity_ids_true():
|
||||
def test_entities_entity_ids_true() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"entity_ids": True}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -75,14 +75,14 @@ def test_entities_entity_ids_true():
|
|||
assert compiled("light.kitchen", "read") is True
|
||||
|
||||
|
||||
def test_entities_entity_ids_false():
|
||||
def test_entities_entity_ids_false() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"entity_ids": False}
|
||||
with pytest.raises(vol.Invalid):
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
||||
|
||||
def test_entities_entity_ids_entity_id_true():
|
||||
def test_entities_entity_ids_entity_id_true() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"entity_ids": {"light.kitchen": True}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -91,14 +91,14 @@ def test_entities_entity_ids_entity_id_true():
|
|||
assert compiled("switch.kitchen", "read") is False
|
||||
|
||||
|
||||
def test_entities_entity_ids_entity_id_false():
|
||||
def test_entities_entity_ids_entity_id_false() -> None:
|
||||
"""Test entity ID policy."""
|
||||
policy = {"entity_ids": {"light.kitchen": False}}
|
||||
with pytest.raises(vol.Invalid):
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
||||
|
||||
def test_entities_control_only():
|
||||
def test_entities_control_only() -> None:
|
||||
"""Test policy granting control only."""
|
||||
policy = {"entity_ids": {"light.kitchen": {"read": True}}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -108,7 +108,7 @@ def test_entities_control_only():
|
|||
assert compiled("light.kitchen", "edit") is False
|
||||
|
||||
|
||||
def test_entities_read_control():
|
||||
def test_entities_read_control() -> None:
|
||||
"""Test policy granting control only."""
|
||||
policy = {"domains": {"light": {"read": True, "control": True}}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -118,7 +118,7 @@ def test_entities_read_control():
|
|||
assert compiled("light.kitchen", "edit") is False
|
||||
|
||||
|
||||
def test_entities_all_allow():
|
||||
def test_entities_all_allow() -> None:
|
||||
"""Test policy allowing all entities."""
|
||||
policy = {"all": True}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -128,7 +128,7 @@ def test_entities_all_allow():
|
|||
assert compiled("switch.kitchen", "read") is True
|
||||
|
||||
|
||||
def test_entities_all_read():
|
||||
def test_entities_all_read() -> None:
|
||||
"""Test policy applying read to all entities."""
|
||||
policy = {"all": {"read": True}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -138,7 +138,7 @@ def test_entities_all_read():
|
|||
assert compiled("switch.kitchen", "read") is True
|
||||
|
||||
|
||||
def test_entities_all_control():
|
||||
def test_entities_all_control() -> None:
|
||||
"""Test entity ID policy applying control to all."""
|
||||
policy = {"all": {"control": True}}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
@ -181,7 +181,7 @@ def test_entities_device_id_boolean(hass):
|
|||
assert compiled("test_domain.not_allowed", "control") is False
|
||||
|
||||
|
||||
def test_entities_areas_true():
|
||||
def test_entities_areas_true() -> None:
|
||||
"""Test entity ID policy for areas."""
|
||||
policy = {"area_ids": True}
|
||||
ENTITY_POLICY_SCHEMA(policy)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from homeassistant.auth.permissions.merge import merge_policies
|
||||
|
||||
|
||||
def test_merging_permissions_true_rules_dict():
|
||||
def test_merging_permissions_true_rules_dict() -> None:
|
||||
"""Test merging policy with two entities."""
|
||||
policy1 = {
|
||||
"something_else": True,
|
||||
|
@ -15,7 +15,7 @@ def test_merging_permissions_true_rules_dict():
|
|||
}
|
||||
|
||||
|
||||
def test_merging_permissions_multiple_subcategories():
|
||||
def test_merging_permissions_multiple_subcategories() -> None:
|
||||
"""Test merging policy with two entities."""
|
||||
policy1 = {"entities": None}
|
||||
policy2 = {"entities": {"entity_ids": True}}
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.auth.permissions import (
|
|||
)
|
||||
|
||||
|
||||
def test_admin_policy():
|
||||
def test_admin_policy() -> None:
|
||||
"""Test admin policy works."""
|
||||
# Make sure it's valid
|
||||
POLICY_SCHEMA(system_policies.ADMIN_POLICY)
|
||||
|
@ -17,7 +17,7 @@ def test_admin_policy():
|
|||
assert perms.check_entity("light.kitchen", "edit")
|
||||
|
||||
|
||||
def test_user_policy():
|
||||
def test_user_policy() -> None:
|
||||
"""Test user policy works."""
|
||||
# Make sure it's valid
|
||||
POLICY_SCHEMA(system_policies.USER_POLICY)
|
||||
|
@ -28,7 +28,7 @@ def test_user_policy():
|
|||
assert perms.check_entity("light.kitchen", "edit")
|
||||
|
||||
|
||||
def test_read_only_policy():
|
||||
def test_read_only_policy() -> None:
|
||||
"""Test read only policy works."""
|
||||
# Make sure it's valid
|
||||
POLICY_SCHEMA(system_policies.READ_ONLY_POLICY)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from homeassistant.auth.permissions import util
|
||||
|
||||
|
||||
def test_test_all():
|
||||
def test_test_all() -> None:
|
||||
"""Test if we can test the all group."""
|
||||
for val in (None, {}, {"all": None}, {"all": {}}):
|
||||
assert util.test_all(val, "read") is False
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from homeassistant.auth import models, permissions
|
||||
|
||||
|
||||
def test_owner_fetching_owner_permissions():
|
||||
def test_owner_fetching_owner_permissions() -> None:
|
||||
"""Test we fetch the owner permissions for an owner user."""
|
||||
group = models.Group(name="Test Group", policy={})
|
||||
owner = models.User(
|
||||
|
@ -11,7 +11,7 @@ def test_owner_fetching_owner_permissions():
|
|||
assert owner.permissions is permissions.OwnerPermissions
|
||||
|
||||
|
||||
def test_permissions_merged():
|
||||
def test_permissions_merged() -> None:
|
||||
"""Test we merge the groups permissions."""
|
||||
group = models.Group(
|
||||
name="Test Group", policy={"entities": {"domains": {"switch": True}}}
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
from homeassistant.backports.enum import StrEnum
|
||||
|
||||
|
||||
def test_strenum():
|
||||
def test_strenum() -> None:
|
||||
"""Test StrEnum."""
|
||||
|
||||
class TestEnum(StrEnum):
|
||||
|
|
|
@ -79,7 +79,7 @@ def test_create_api_message_defaults(hass):
|
|||
assert msg["endpoint"] is not request["directive"]["endpoint"]
|
||||
|
||||
|
||||
def test_create_api_message_special():
|
||||
def test_create_api_message_special() -> None:
|
||||
"""Create an API message response of a request with non defaults."""
|
||||
request = get_new_request("Alexa.PowerController", "TurnOn")
|
||||
directive_header = request["directive"]["header"]
|
||||
|
|
|
@ -15,44 +15,44 @@ TEST_HOST = "testhost"
|
|||
TEST_PASSWORD = "testpass"
|
||||
|
||||
|
||||
def test_make_filter():
|
||||
def test_make_filter() -> None:
|
||||
"""Test filter."""
|
||||
callsigns = ["CALLSIGN1", "callsign2"]
|
||||
res = device_tracker.make_filter(callsigns)
|
||||
assert res == "b/CALLSIGN1 b/CALLSIGN2"
|
||||
|
||||
|
||||
def test_gps_accuracy_0():
|
||||
def test_gps_accuracy_0() -> None:
|
||||
"""Test GPS accuracy level 0."""
|
||||
acc = device_tracker.gps_accuracy(TEST_COORDS_NULL_ISLAND, 0)
|
||||
assert acc == 0
|
||||
|
||||
|
||||
def test_gps_accuracy_1():
|
||||
def test_gps_accuracy_1() -> None:
|
||||
"""Test GPS accuracy level 1."""
|
||||
acc = device_tracker.gps_accuracy(TEST_COORDS_NULL_ISLAND, 1)
|
||||
assert acc == 186
|
||||
|
||||
|
||||
def test_gps_accuracy_2():
|
||||
def test_gps_accuracy_2() -> None:
|
||||
"""Test GPS accuracy level 2."""
|
||||
acc = device_tracker.gps_accuracy(TEST_COORDS_NULL_ISLAND, 2)
|
||||
assert acc == 1855
|
||||
|
||||
|
||||
def test_gps_accuracy_3():
|
||||
def test_gps_accuracy_3() -> None:
|
||||
"""Test GPS accuracy level 3."""
|
||||
acc = device_tracker.gps_accuracy(TEST_COORDS_NULL_ISLAND, 3)
|
||||
assert acc == 18553
|
||||
|
||||
|
||||
def test_gps_accuracy_4():
|
||||
def test_gps_accuracy_4() -> None:
|
||||
"""Test GPS accuracy level 4."""
|
||||
acc = device_tracker.gps_accuracy(TEST_COORDS_NULL_ISLAND, 4)
|
||||
assert acc == 111319
|
||||
|
||||
|
||||
def test_gps_accuracy_invalid_int():
|
||||
def test_gps_accuracy_invalid_int() -> None:
|
||||
"""Test GPS accuracy with invalid input."""
|
||||
level = 5
|
||||
|
||||
|
@ -63,7 +63,7 @@ def test_gps_accuracy_invalid_int():
|
|||
pass
|
||||
|
||||
|
||||
def test_gps_accuracy_invalid_string():
|
||||
def test_gps_accuracy_invalid_string() -> None:
|
||||
"""Test GPS accuracy with invalid input."""
|
||||
level = "not an int"
|
||||
|
||||
|
@ -74,7 +74,7 @@ def test_gps_accuracy_invalid_string():
|
|||
pass
|
||||
|
||||
|
||||
def test_gps_accuracy_invalid_float():
|
||||
def test_gps_accuracy_invalid_float() -> None:
|
||||
"""Test GPS accuracy with invalid input."""
|
||||
level = 1.2
|
||||
|
||||
|
@ -85,7 +85,7 @@ def test_gps_accuracy_invalid_float():
|
|||
pass
|
||||
|
||||
|
||||
def test_aprs_listener():
|
||||
def test_aprs_listener() -> None:
|
||||
"""Test listener thread."""
|
||||
with patch("aprslib.IS") as mock_ais:
|
||||
callsign = TEST_CALLSIGN
|
||||
|
@ -110,7 +110,7 @@ def test_aprs_listener():
|
|||
mock_ais.assert_called_with(callsign, passwd=password, host=host, port=port)
|
||||
|
||||
|
||||
def test_aprs_listener_start_fail():
|
||||
def test_aprs_listener_start_fail() -> None:
|
||||
"""Test listener thread start failure."""
|
||||
with patch(
|
||||
"aprslib.IS.connect", side_effect=aprslib.ConnectionError("Unable to connect.")
|
||||
|
@ -135,7 +135,7 @@ def test_aprs_listener_start_fail():
|
|||
assert listener.start_message == "Unable to connect."
|
||||
|
||||
|
||||
def test_aprs_listener_stop():
|
||||
def test_aprs_listener_stop() -> None:
|
||||
"""Test listener thread stop."""
|
||||
with patch("aprslib.IS"):
|
||||
callsign = TEST_CALLSIGN
|
||||
|
@ -161,7 +161,7 @@ def test_aprs_listener_stop():
|
|||
listener.ais.close.assert_called_with()
|
||||
|
||||
|
||||
def test_aprs_listener_rx_msg():
|
||||
def test_aprs_listener_rx_msg() -> None:
|
||||
"""Test rx_msg."""
|
||||
with patch("aprslib.IS"):
|
||||
callsign = TEST_CALLSIGN
|
||||
|
@ -198,7 +198,7 @@ def test_aprs_listener_rx_msg():
|
|||
)
|
||||
|
||||
|
||||
def test_aprs_listener_rx_msg_ambiguity():
|
||||
def test_aprs_listener_rx_msg_ambiguity() -> None:
|
||||
"""Test rx_msg with posambiguity."""
|
||||
with patch("aprslib.IS"):
|
||||
callsign = TEST_CALLSIGN
|
||||
|
@ -235,7 +235,7 @@ def test_aprs_listener_rx_msg_ambiguity():
|
|||
)
|
||||
|
||||
|
||||
def test_aprs_listener_rx_msg_ambiguity_invalid():
|
||||
def test_aprs_listener_rx_msg_ambiguity_invalid() -> None:
|
||||
"""Test rx_msg with invalid posambiguity."""
|
||||
with patch("aprslib.IS"):
|
||||
callsign = TEST_CALLSIGN
|
||||
|
@ -270,7 +270,7 @@ def test_aprs_listener_rx_msg_ambiguity_invalid():
|
|||
)
|
||||
|
||||
|
||||
def test_aprs_listener_rx_msg_no_position():
|
||||
def test_aprs_listener_rx_msg_no_position() -> None:
|
||||
"""Test rx_msg with non-position report."""
|
||||
with patch("aprslib.IS"):
|
||||
callsign = TEST_CALLSIGN
|
||||
|
|
|
@ -23,7 +23,7 @@ def mock_session():
|
|||
yield mocker
|
||||
|
||||
|
||||
def test_client_id_scheme():
|
||||
def test_client_id_scheme() -> None:
|
||||
"""Test we enforce valid scheme."""
|
||||
assert indieauth._parse_client_id("http://ex.com/")
|
||||
assert indieauth._parse_client_id("https://ex.com/")
|
||||
|
@ -32,7 +32,7 @@ def test_client_id_scheme():
|
|||
indieauth._parse_client_id("ftp://ex.com")
|
||||
|
||||
|
||||
def test_client_id_path():
|
||||
def test_client_id_path() -> None:
|
||||
"""Test we enforce valid path."""
|
||||
assert indieauth._parse_client_id("http://ex.com").path == "/"
|
||||
assert indieauth._parse_client_id("http://ex.com/hello").path == "/hello"
|
||||
|
@ -54,13 +54,13 @@ def test_client_id_path():
|
|||
indieauth._parse_client_id("http://ex.com/hello/../yo")
|
||||
|
||||
|
||||
def test_client_id_fragment():
|
||||
def test_client_id_fragment() -> None:
|
||||
"""Test we enforce valid fragment."""
|
||||
with pytest.raises(ValueError):
|
||||
indieauth._parse_client_id("http://ex.com/#yoo")
|
||||
|
||||
|
||||
def test_client_id_user_pass():
|
||||
def test_client_id_user_pass() -> None:
|
||||
"""Test we enforce valid username/password."""
|
||||
with pytest.raises(ValueError):
|
||||
indieauth._parse_client_id("http://user@ex.com/")
|
||||
|
@ -69,7 +69,7 @@ def test_client_id_user_pass():
|
|||
indieauth._parse_client_id("http://user:pass@ex.com/")
|
||||
|
||||
|
||||
def test_client_id_hostname():
|
||||
def test_client_id_hostname() -> None:
|
||||
"""Test we enforce valid hostname."""
|
||||
assert indieauth._parse_client_id("http://www.home-assistant.io/")
|
||||
assert indieauth._parse_client_id("http://[::1]")
|
||||
|
@ -91,7 +91,7 @@ def test_client_id_hostname():
|
|||
assert indieauth._parse_client_id("http://192.167.0.0/")
|
||||
|
||||
|
||||
def test_parse_url_lowercase_host():
|
||||
def test_parse_url_lowercase_host() -> None:
|
||||
"""Test we update empty paths."""
|
||||
assert indieauth._parse_url("http://ex.com/hello").path == "/hello"
|
||||
assert indieauth._parse_url("http://EX.COM/hello").hostname == "ex.com"
|
||||
|
@ -101,7 +101,7 @@ def test_parse_url_lowercase_host():
|
|||
assert parts.path == "/HELLO"
|
||||
|
||||
|
||||
def test_parse_url_path():
|
||||
def test_parse_url_path() -> None:
|
||||
"""Test we update empty paths."""
|
||||
assert indieauth._parse_url("http://ex.com").path == "/"
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from homeassistant.components import binary_sensor
|
|||
from homeassistant.const import STATE_OFF, STATE_ON
|
||||
|
||||
|
||||
def test_state():
|
||||
def test_state() -> None:
|
||||
"""Test binary sensor state."""
|
||||
sensor = binary_sensor.BinarySensorEntity()
|
||||
assert sensor.state is None
|
||||
|
|
|
@ -53,7 +53,7 @@ class MockBlackbird:
|
|||
self.zones[3].av = source_idx
|
||||
|
||||
|
||||
def test_valid_serial_schema():
|
||||
def test_valid_serial_schema() -> None:
|
||||
"""Test valid schema."""
|
||||
valid_schema = {
|
||||
"platform": "blackbird",
|
||||
|
@ -82,7 +82,7 @@ def test_valid_serial_schema():
|
|||
PLATFORM_SCHEMA(valid_schema)
|
||||
|
||||
|
||||
def test_valid_socket_schema():
|
||||
def test_valid_socket_schema() -> None:
|
||||
"""Test valid schema."""
|
||||
valid_schema = {
|
||||
"platform": "blackbird",
|
||||
|
@ -104,7 +104,7 @@ def test_valid_socket_schema():
|
|||
PLATFORM_SCHEMA(valid_schema)
|
||||
|
||||
|
||||
def test_invalid_schemas():
|
||||
def test_invalid_schemas() -> None:
|
||||
"""Test invalid schemas."""
|
||||
schemas = (
|
||||
{}, # Empty
|
||||
|
|
|
@ -84,7 +84,7 @@ COMMUNITY_POST_INPUTS = {
|
|||
}
|
||||
|
||||
|
||||
def test_get_community_post_import_url():
|
||||
def test_get_community_post_import_url() -> None:
|
||||
"""Test variations of generating import forum url."""
|
||||
assert (
|
||||
importer._get_community_post_import_url(
|
||||
|
@ -101,7 +101,7 @@ def test_get_community_post_import_url():
|
|||
)
|
||||
|
||||
|
||||
def test_get_github_import_url():
|
||||
def test_get_github_import_url() -> None:
|
||||
"""Test getting github import url."""
|
||||
assert (
|
||||
importer._get_github_import_url(
|
||||
|
@ -128,7 +128,7 @@ def test_extract_blueprint_from_community_topic(community_post):
|
|||
assert imported_blueprint.blueprint.inputs == COMMUNITY_POST_INPUTS
|
||||
|
||||
|
||||
def test_extract_blueprint_from_community_topic_invalid_yaml():
|
||||
def test_extract_blueprint_from_community_topic_invalid_yaml() -> None:
|
||||
"""Test extracting blueprint with invalid YAML."""
|
||||
with pytest.raises(HomeAssistantError):
|
||||
importer._extract_blueprint_from_community_topic(
|
||||
|
@ -143,7 +143,7 @@ def test_extract_blueprint_from_community_topic_invalid_yaml():
|
|||
)
|
||||
|
||||
|
||||
def test_extract_blueprint_from_community_topic_wrong_lang():
|
||||
def test_extract_blueprint_from_community_topic_wrong_lang() -> None:
|
||||
"""Test extracting blueprint with invalid YAML."""
|
||||
with pytest.raises(importer.HomeAssistantError):
|
||||
assert importer._extract_blueprint_from_community_topic(
|
||||
|
|
|
@ -52,7 +52,7 @@ def domain_bps(hass):
|
|||
)
|
||||
|
||||
|
||||
def test_blueprint_model_init():
|
||||
def test_blueprint_model_init() -> None:
|
||||
"""Test constructor validation."""
|
||||
with pytest.raises(errors.InvalidBlueprint):
|
||||
models.Blueprint({})
|
||||
|
@ -91,7 +91,7 @@ def test_blueprint_properties(blueprint_1):
|
|||
}
|
||||
|
||||
|
||||
def test_blueprint_update_metadata():
|
||||
def test_blueprint_update_metadata() -> None:
|
||||
"""Test update metadata."""
|
||||
bp = models.Blueprint(
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ def test_blueprint_update_metadata():
|
|||
assert bp.metadata["source_url"] == "http://bla.com"
|
||||
|
||||
|
||||
def test_blueprint_validate():
|
||||
def test_blueprint_validate() -> None:
|
||||
"""Test validate blueprint."""
|
||||
assert (
|
||||
models.Blueprint(
|
||||
|
|
|
@ -24,13 +24,13 @@ def _reset_turbojpeg_singleton():
|
|||
TurboJPEGSingleton.__instance = TurboJPEG()
|
||||
|
||||
|
||||
def test_turbojpeg_singleton():
|
||||
def test_turbojpeg_singleton() -> None:
|
||||
"""Verify the instance always gives back the same."""
|
||||
_clear_turbojpeg_singleton()
|
||||
assert TurboJPEGSingleton.instance() == TurboJPEGSingleton.instance()
|
||||
|
||||
|
||||
def test_scale_jpeg_camera_image():
|
||||
def test_scale_jpeg_camera_image() -> None:
|
||||
"""Test we can scale a jpeg image."""
|
||||
_clear_turbojpeg_singleton()
|
||||
|
||||
|
@ -71,7 +71,7 @@ def test_scale_jpeg_camera_image():
|
|||
assert jpeg_bytes == EMPTY_16_12_JPEG
|
||||
|
||||
|
||||
def test_turbojpeg_load_failure():
|
||||
def test_turbojpeg_load_failure() -> None:
|
||||
"""Handle libjpegturbo not being installed."""
|
||||
_clear_turbojpeg_singleton()
|
||||
with patch("turbojpeg.TurboJPEG", side_effect=Exception):
|
||||
|
|
|
@ -14,12 +14,12 @@ def cloud_with_prefs(cloud_prefs):
|
|||
return Mock(client=Mock(prefs=cloud_prefs))
|
||||
|
||||
|
||||
def test_default_exists():
|
||||
def test_default_exists() -> None:
|
||||
"""Test our default language exists."""
|
||||
assert const.DEFAULT_TTS_DEFAULT_VOICE in voice.MAP_VOICE
|
||||
|
||||
|
||||
def test_schema():
|
||||
def test_schema() -> None:
|
||||
"""Test schema."""
|
||||
assert "nl-NL" in tts.SUPPORT_LANGUAGES
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from homeassistant.components.conversation.util import create_matcher
|
||||
|
||||
|
||||
def test_create_matcher():
|
||||
def test_create_matcher() -> None:
|
||||
"""Test the create matcher method."""
|
||||
# Basic sentence
|
||||
pattern = create_matcher("Hello world")
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
from homeassistant.components.daikin.climate import format_target_temperature
|
||||
|
||||
|
||||
def test_int_conversion():
|
||||
def test_int_conversion() -> None:
|
||||
"""Check no decimal are kept when target temp is an integer."""
|
||||
formatted = format_target_temperature("16")
|
||||
assert formatted == "16"
|
||||
|
||||
|
||||
def test_rounding():
|
||||
def test_rounding() -> None:
|
||||
"""Check 1 decimal is kept when target temp is a decimal."""
|
||||
formatted = format_target_temperature("16.1")
|
||||
assert formatted == "16"
|
||||
|
|
|
@ -12,7 +12,7 @@ from tests.common import (
|
|||
)
|
||||
|
||||
|
||||
def test_tracker_entity():
|
||||
def test_tracker_entity() -> None:
|
||||
"""Test tracker entity."""
|
||||
|
||||
class TestEntry(ce.TrackerEntity):
|
||||
|
|
|
@ -53,7 +53,7 @@ async def test_scanner_entity_device_tracker(hass, enable_custom_integrations):
|
|||
assert entity_state.state == STATE_HOME
|
||||
|
||||
|
||||
def test_scanner_entity():
|
||||
def test_scanner_entity() -> None:
|
||||
"""Test coverage for base ScannerEntity entity class."""
|
||||
entity = ScannerEntity()
|
||||
with pytest.raises(NotImplementedError):
|
||||
|
@ -68,7 +68,7 @@ def test_scanner_entity():
|
|||
assert entity.hostname is None
|
||||
|
||||
|
||||
def test_base_tracker_entity():
|
||||
def test_base_tracker_entity() -> None:
|
||||
"""Test coverage for base BaseTrackerEntity entity class."""
|
||||
entity = BaseTrackerEntity()
|
||||
with pytest.raises(NotImplementedError):
|
||||
|
|
|
@ -629,7 +629,7 @@ async def test_old_style_track_new_is_skipped(mock_device_tracker_conf, hass):
|
|||
assert mock_device_tracker_conf[0].track is False
|
||||
|
||||
|
||||
def test_see_schema_allowing_ios_calls():
|
||||
def test_see_schema_allowing_ios_calls() -> None:
|
||||
"""Test SEE service schema allows extra keys.
|
||||
|
||||
Temp work around because the iOS app sends incorrect data.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from homeassistant.components.diagnostics import REDACTED, async_redact_data
|
||||
|
||||
|
||||
def test_redact():
|
||||
def test_redact() -> None:
|
||||
"""Test the async_redact_data helper."""
|
||||
data = {
|
||||
"key1": "value1",
|
||||
|
|
|
@ -569,7 +569,7 @@ async def test_options_flow(hass):
|
|||
assert entry.options == {"time_between_update": 15}
|
||||
|
||||
|
||||
def test_get_serial_by_id_no_dir():
|
||||
def test_get_serial_by_id_no_dir() -> None:
|
||||
"""Test serial by id conversion if there's no /dev/serial/by-id."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=False))
|
||||
p2 = patch("os.scandir")
|
||||
|
@ -580,7 +580,7 @@ def test_get_serial_by_id_no_dir():
|
|||
assert scan_mock.call_count == 0
|
||||
|
||||
|
||||
def test_get_serial_by_id():
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
|
|
@ -102,7 +102,7 @@ async def test_config_google_home_entity_id_to_number_empty(hass, hass_storage):
|
|||
assert entity_id == "light.test2"
|
||||
|
||||
|
||||
def test_config_alexa_entity_id_to_number():
|
||||
def test_config_alexa_entity_id_to_number() -> None:
|
||||
"""Test config adheres to the type."""
|
||||
conf = Config(None, {"type": "alexa"}, "127.0.0.1")
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ async def setup_hue(hass):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
def test_upnp_discovery_basic():
|
||||
def test_upnp_discovery_basic() -> None:
|
||||
"""Tests the UPnP basic discovery response."""
|
||||
upnp_responder_protocol = upnp.UPNPResponderProtocol(None, None, "192.0.2.42", 8080)
|
||||
mock_transport = MockTransport()
|
||||
|
@ -96,7 +96,7 @@ USN: uuid:2f402f80-da50-11e1-9b23-001788255acc
|
|||
assert mock_transport.sends == [(expected_send, 1234)]
|
||||
|
||||
|
||||
def test_upnp_discovery_rootdevice():
|
||||
def test_upnp_discovery_rootdevice() -> None:
|
||||
"""Tests the UPnP rootdevice discovery response."""
|
||||
upnp_responder_protocol = upnp.UPNPResponderProtocol(None, None, "192.0.2.42", 8080)
|
||||
mock_transport = MockTransport()
|
||||
|
@ -128,7 +128,7 @@ USN: uuid:2f402f80-da50-11e1-9b23-001788255acc::upnp:rootdevice
|
|||
assert mock_transport.sends == [(expected_send, 1234)]
|
||||
|
||||
|
||||
def test_upnp_no_response():
|
||||
def test_upnp_no_response() -> None:
|
||||
"""Tests the UPnP does not response on an invalid request."""
|
||||
upnp_responder_protocol = upnp.UPNPResponderProtocol(None, None, "192.0.2.42", 8080)
|
||||
mock_transport = MockTransport()
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
from homeassistant.components.everlights import light as everlights
|
||||
|
||||
|
||||
def test_color_rgb_to_int():
|
||||
def test_color_rgb_to_int() -> None:
|
||||
"""Test RGB to integer conversion."""
|
||||
assert everlights.color_rgb_to_int(0x00, 0x00, 0x00) == 0x000000
|
||||
assert everlights.color_rgb_to_int(0xFF, 0xFF, 0xFF) == 0xFFFFFF
|
||||
assert everlights.color_rgb_to_int(0x12, 0x34, 0x56) == 0x123456
|
||||
|
||||
|
||||
def test_int_to_rgb():
|
||||
def test_int_to_rgb() -> None:
|
||||
"""Test integer to RGB conversion."""
|
||||
assert everlights.color_int_to_rgb(0x000000) == (0x00, 0x00, 0x00)
|
||||
assert everlights.color_int_to_rgb(0xFFFFFF) == (0xFF, 0xFF, 0xFF)
|
||||
|
|
|
@ -130,23 +130,23 @@ def test_check_box_health(caplog):
|
|||
assert "ConnectionError: Is facebox running?" in caplog.text
|
||||
|
||||
|
||||
def test_encode_image():
|
||||
def test_encode_image() -> None:
|
||||
"""Test that binary data is encoded correctly."""
|
||||
assert fb.encode_image(b"test") == "dGVzdA=="
|
||||
|
||||
|
||||
def test_get_matched_faces():
|
||||
def test_get_matched_faces() -> None:
|
||||
"""Test that matched_faces are parsed correctly."""
|
||||
assert fb.get_matched_faces(PARSED_FACES) == MATCHED_FACES
|
||||
|
||||
|
||||
def test_parse_faces():
|
||||
def test_parse_faces() -> None:
|
||||
"""Test parsing of raw face data, and generation of matched_faces."""
|
||||
assert fb.parse_faces(MOCK_JSON["faces"]) == PARSED_FACES
|
||||
|
||||
|
||||
@patch("os.access", Mock(return_value=False))
|
||||
def test_valid_file_path():
|
||||
def test_valid_file_path() -> None:
|
||||
"""Test that an invalid file_path is caught."""
|
||||
assert not fb.valid_file_path("test_path")
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class BaseFan(FanEntity):
|
|||
"""Initialize the fan."""
|
||||
|
||||
|
||||
def test_fanentity():
|
||||
def test_fanentity() -> None:
|
||||
"""Test fan entity methods."""
|
||||
fan = BaseFan()
|
||||
assert fan.state == "off"
|
||||
|
|
|
@ -28,7 +28,7 @@ async def test_valid_path_setup(hass):
|
|||
)
|
||||
|
||||
|
||||
def test_event():
|
||||
def test_event() -> None:
|
||||
"""Check that Home Assistant events are fired correctly on watchdog event."""
|
||||
|
||||
class MockPatternMatchingEventHandler:
|
||||
|
@ -58,7 +58,7 @@ def test_event():
|
|||
}
|
||||
|
||||
|
||||
def test_move_event():
|
||||
def test_move_event() -> None:
|
||||
"""Check that Home Assistant events are fired correctly on watchdog event."""
|
||||
|
||||
class MockPatternMatchingEventHandler:
|
||||
|
|
|
@ -332,7 +332,7 @@ def test_supported_features_string(caplog):
|
|||
assert "Entity test.entity_id contains invalid supported_features value invalid"
|
||||
|
||||
|
||||
def test_request_data():
|
||||
def test_request_data() -> None:
|
||||
"""Test request data properties."""
|
||||
config = MockConfig()
|
||||
data = helpers.RequestData(
|
||||
|
@ -428,7 +428,7 @@ async def test_config_local_sdk_warn_version(hass, hass_client, caplog, version)
|
|||
) in caplog.text
|
||||
|
||||
|
||||
def test_is_supported_cached():
|
||||
def test_is_supported_cached() -> None:
|
||||
"""Test is_supported is cached."""
|
||||
config = MockConfig()
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ def listeners_without_writes(listeners: dict[str, int]) -> dict[str, int]:
|
|||
|
||||
|
||||
@pytest.mark.usefixtures("hass_history")
|
||||
def test_setup():
|
||||
def test_setup() -> None:
|
||||
"""Test setup method of history."""
|
||||
# Verification occurs in the fixture
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ def db_schema_30():
|
|||
|
||||
|
||||
@pytest.mark.usefixtures("hass_history")
|
||||
def test_setup():
|
||||
def test_setup() -> None:
|
||||
"""Test setup method of history."""
|
||||
# Verification occurs in the fixture
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ def listeners_without_writes(listeners: dict[str, int]) -> dict[str, int]:
|
|||
|
||||
|
||||
@pytest.mark.usefixtures("hass_history")
|
||||
def test_setup():
|
||||
def test_setup() -> None:
|
||||
"""Test setup method of history."""
|
||||
# Verification occurs in the fixture
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ async def test_config(hass):
|
|||
assert "icon" not in no_icon.attributes
|
||||
|
||||
|
||||
def test_validator():
|
||||
def test_validator() -> None:
|
||||
"""Test validators."""
|
||||
parsed = ha_scene.STATES_SCHEMA({"light.Test": {"state": "on"}})
|
||||
assert len(parsed) == 1
|
||||
|
|
|
@ -46,7 +46,7 @@ def test_not_supported(caplog):
|
|||
assert "invalid aid" in caplog.records[0].msg
|
||||
|
||||
|
||||
def test_not_supported_media_player():
|
||||
def test_not_supported_media_player() -> None:
|
||||
"""Test if mode isn't supported and if no supported modes."""
|
||||
# selected mode for entity not supported
|
||||
config = {CONF_FEATURE_LIST: {FEATURE_ON_OFF: None}}
|
||||
|
|
|
@ -73,7 +73,7 @@ def _mock_socket(failure_attempts: int = 0) -> MagicMock:
|
|||
return mock_socket
|
||||
|
||||
|
||||
def test_validate_entity_config():
|
||||
def test_validate_entity_config() -> None:
|
||||
"""Test validate entities."""
|
||||
configs = [
|
||||
None,
|
||||
|
@ -173,7 +173,7 @@ def test_validate_entity_config():
|
|||
}
|
||||
|
||||
|
||||
def test_validate_media_player_features():
|
||||
def test_validate_media_player_features() -> None:
|
||||
"""Test validate modes for media players."""
|
||||
config = {}
|
||||
attrs = {ATTR_SUPPORTED_FEATURES: 20873}
|
||||
|
@ -187,7 +187,7 @@ def test_validate_media_player_features():
|
|||
assert validate_media_player_features(entity_state, config) is False
|
||||
|
||||
|
||||
def test_convert_to_float():
|
||||
def test_convert_to_float() -> None:
|
||||
"""Test convert_to_float method."""
|
||||
assert convert_to_float(12) == 12
|
||||
assert convert_to_float(12.4) == 12.4
|
||||
|
@ -195,7 +195,7 @@ def test_convert_to_float():
|
|||
assert convert_to_float(None) is None
|
||||
|
||||
|
||||
def test_cleanup_name_for_homekit():
|
||||
def test_cleanup_name_for_homekit() -> None:
|
||||
"""Ensure name sanitize works as expected."""
|
||||
|
||||
assert cleanup_name_for_homekit("abc") == "abc"
|
||||
|
@ -208,19 +208,19 @@ def test_cleanup_name_for_homekit():
|
|||
assert cleanup_name_for_homekit("の日本_語文字セット") == "の日本 語文字セット"
|
||||
|
||||
|
||||
def test_temperature_to_homekit():
|
||||
def test_temperature_to_homekit() -> None:
|
||||
"""Test temperature conversion from HA to HomeKit."""
|
||||
assert temperature_to_homekit(20.46, UnitOfTemperature.CELSIUS) == 20.5
|
||||
assert temperature_to_homekit(92.1, UnitOfTemperature.FAHRENHEIT) == 33.4
|
||||
|
||||
|
||||
def test_temperature_to_states():
|
||||
def test_temperature_to_states() -> None:
|
||||
"""Test temperature conversion from HomeKit to HA."""
|
||||
assert temperature_to_states(20, UnitOfTemperature.CELSIUS) == 20.0
|
||||
assert temperature_to_states(20.2, UnitOfTemperature.FAHRENHEIT) == 68.5
|
||||
|
||||
|
||||
def test_density_to_air_quality():
|
||||
def test_density_to_air_quality() -> None:
|
||||
"""Test map PM2.5 density to HomeKit AirQuality level."""
|
||||
assert density_to_air_quality(0) == 1
|
||||
assert density_to_air_quality(12) == 1
|
||||
|
|
|
@ -331,7 +331,7 @@ async def test_sensor_unavailable(hass, utcnow):
|
|||
assert state.state == "unavailable"
|
||||
|
||||
|
||||
def test_thread_node_caps_to_str():
|
||||
def test_thread_node_caps_to_str() -> None:
|
||||
"""Test all values of this enum get a translatable string."""
|
||||
assert (
|
||||
thread_node_capability_to_str(ThreadNodeCapabilities.BORDER_ROUTER_CAPABLE)
|
||||
|
@ -347,7 +347,7 @@ def test_thread_node_caps_to_str():
|
|||
assert thread_node_capability_to_str(ThreadNodeCapabilities(128)) == "none"
|
||||
|
||||
|
||||
def test_thread_status_to_str():
|
||||
def test_thread_status_to_str() -> None:
|
||||
"""Test all values of this enum get a translatable string."""
|
||||
assert thread_status_to_str(ThreadStatus.BORDER_ROUTER) == "border_router"
|
||||
assert thread_status_to_str(ThreadStatus.LEADER) == "leader"
|
||||
|
|
|
@ -650,7 +650,7 @@ async def test_light_turn_off_service(hass, mock_bridge_v1):
|
|||
assert light.state == "off"
|
||||
|
||||
|
||||
def test_available():
|
||||
def test_available() -> None:
|
||||
"""Test available property."""
|
||||
light = hue_light.HueLight(
|
||||
light=Mock(
|
||||
|
@ -704,7 +704,7 @@ def test_available():
|
|||
assert light.available is True
|
||||
|
||||
|
||||
def test_hs_color():
|
||||
def test_hs_color() -> None:
|
||||
"""Test hs_color property."""
|
||||
light = hue_light.HueLight(
|
||||
light=Mock(
|
||||
|
|
|
@ -2348,7 +2348,7 @@ async def test_services_filter_parameters(
|
|||
assert data == {}
|
||||
|
||||
|
||||
def test_valid_supported_color_modes():
|
||||
def test_valid_supported_color_modes() -> None:
|
||||
"""Test valid_supported_color_modes."""
|
||||
supported = {light.ColorMode.HS}
|
||||
assert light.valid_supported_color_modes(supported) == supported
|
||||
|
@ -2387,7 +2387,7 @@ def test_valid_supported_color_modes():
|
|||
light.valid_supported_color_modes(supported)
|
||||
|
||||
|
||||
def test_filter_supported_color_modes():
|
||||
def test_filter_supported_color_modes() -> None:
|
||||
"""Test filter_supported_color_modes."""
|
||||
supported = {light.ColorMode.HS}
|
||||
assert light.filter_supported_color_modes(supported) == supported
|
||||
|
|
|
@ -635,7 +635,7 @@ async def test_publish_function_with_bad_encoding_conditions(
|
|||
)
|
||||
|
||||
|
||||
def test_validate_topic():
|
||||
def test_validate_topic() -> None:
|
||||
"""Test topic name/filter validation."""
|
||||
# Invalid UTF-8, must not contain U+D800 to U+DFFF.
|
||||
with pytest.raises(vol.Invalid):
|
||||
|
@ -679,7 +679,7 @@ def test_validate_topic():
|
|||
mqtt.util.valid_topic("\U0001ffff")
|
||||
|
||||
|
||||
def test_validate_subscribe_topic():
|
||||
def test_validate_subscribe_topic() -> None:
|
||||
"""Test invalid subscribe topics."""
|
||||
mqtt.valid_subscribe_topic("#")
|
||||
mqtt.valid_subscribe_topic("sport/#")
|
||||
|
@ -708,7 +708,7 @@ def test_validate_subscribe_topic():
|
|||
mqtt.valid_subscribe_topic("$SYS/#")
|
||||
|
||||
|
||||
def test_validate_publish_topic():
|
||||
def test_validate_publish_topic() -> None:
|
||||
"""Test invalid publish topics."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
mqtt.valid_publish_topic("pub+")
|
||||
|
@ -724,7 +724,7 @@ def test_validate_publish_topic():
|
|||
mqtt.valid_publish_topic("$SYS/")
|
||||
|
||||
|
||||
def test_entity_device_info_schema():
|
||||
def test_entity_device_info_schema() -> None:
|
||||
"""Test MQTT entity device info validation."""
|
||||
# just identifier
|
||||
MQTT_ENTITY_DEVICE_INFO_SCHEMA({"identifiers": ["abcd"]})
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.const import (
|
|||
)
|
||||
|
||||
|
||||
def test_device_custom_name():
|
||||
def test_device_custom_name() -> None:
|
||||
"""Test a device name from an Info trait."""
|
||||
device = Device.MakeDevice(
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ def test_device_custom_name():
|
|||
}
|
||||
|
||||
|
||||
def test_device_name_room():
|
||||
def test_device_name_room() -> None:
|
||||
"""Test a device name from the room name."""
|
||||
device = Device.MakeDevice(
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ def test_device_name_room():
|
|||
}
|
||||
|
||||
|
||||
def test_device_no_name():
|
||||
def test_device_no_name() -> None:
|
||||
"""Test a device that has a name inferred from the type."""
|
||||
device = Device.MakeDevice(
|
||||
{"name": "some-device-id", "type": "sdm.devices.types.DOORBELL", "traits": {}},
|
||||
|
@ -86,7 +86,7 @@ def test_device_no_name():
|
|||
}
|
||||
|
||||
|
||||
def test_device_invalid_type():
|
||||
def test_device_invalid_type() -> None:
|
||||
"""Test a device with a type name that is not recognized."""
|
||||
device = Device.MakeDevice(
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ def test_device_invalid_type():
|
|||
}
|
||||
|
||||
|
||||
def test_suggested_area():
|
||||
def test_suggested_area() -> None:
|
||||
"""Test the suggested area with different device name and room name."""
|
||||
device = Device.MakeDevice(
|
||||
{
|
||||
|
|
|
@ -864,7 +864,7 @@ async def test_custom_unit_change(
|
|||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == default_unit
|
||||
|
||||
|
||||
def test_device_classes_aligned():
|
||||
def test_device_classes_aligned() -> None:
|
||||
"""Make sure all sensor device classes are also available in NumberDeviceClass."""
|
||||
|
||||
non_numeric_device_classes = {
|
||||
|
|
|
@ -145,7 +145,7 @@ def test_nx584_sensor_setup_no_zones(hass):
|
|||
assert not add_entities.called
|
||||
|
||||
|
||||
def test_nx584_zone_sensor_normal():
|
||||
def test_nx584_zone_sensor_normal() -> None:
|
||||
"""Test for the NX584 zone sensor."""
|
||||
zone = {"number": 1, "name": "foo", "state": True}
|
||||
sensor = nx584.NX584ZoneSensor(zone, "motion")
|
||||
|
@ -159,7 +159,7 @@ def test_nx584_zone_sensor_normal():
|
|||
assert not sensor.is_on
|
||||
|
||||
|
||||
def test_nx584_zone_sensor_bypassed():
|
||||
def test_nx584_zone_sensor_bypassed() -> None:
|
||||
"""Test for the NX584 zone sensor."""
|
||||
zone = {"number": 1, "name": "foo", "state": True, "bypassed": True}
|
||||
sensor = nx584.NX584ZoneSensor(zone, "motion")
|
||||
|
@ -198,7 +198,7 @@ def test_nx584_watcher_process_zone_event_missing_zone(mock_update):
|
|||
assert not mock_update.called
|
||||
|
||||
|
||||
def test_nx584_watcher_run_with_zone_events():
|
||||
def test_nx584_watcher_run_with_zone_events() -> None:
|
||||
"""Test the zone events."""
|
||||
empty_me = [1, 2]
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ async def test_returns_error_missing_device(mock_client):
|
|||
assert json == []
|
||||
|
||||
|
||||
def test_context_delivers_pending_msg():
|
||||
def test_context_delivers_pending_msg() -> None:
|
||||
"""Test that context is able to hold pending messages while being init."""
|
||||
context = owntracks.OwnTracksContext(None, None, None, None, None, None, None, None)
|
||||
context.async_see(hello="world")
|
||||
|
|
|
@ -43,7 +43,7 @@ SIMPLE_EXCLUDE_FILTER = {
|
|||
SIMPLE_INCLUDE_EXCLUDE_FILTER = {**SIMPLE_INCLUDE_FILTER, **SIMPLE_EXCLUDE_FILTER}
|
||||
|
||||
|
||||
def test_extract_include_exclude_filter_conf():
|
||||
def test_extract_include_exclude_filter_conf() -> None:
|
||||
"""Test we can extract a filter from configuration without altering it."""
|
||||
include_filter = extract_include_exclude_filter_conf(SIMPLE_INCLUDE_FILTER)
|
||||
assert include_filter == {
|
||||
|
@ -109,7 +109,7 @@ def test_extract_include_exclude_filter_conf():
|
|||
}
|
||||
|
||||
|
||||
def test_merge_include_exclude_filters():
|
||||
def test_merge_include_exclude_filters() -> None:
|
||||
"""Test we can merge two filters together."""
|
||||
include_exclude_filter_base = extract_include_exclude_filter_conf(
|
||||
SIMPLE_INCLUDE_EXCLUDE_FILTER
|
||||
|
|
|
@ -398,7 +398,7 @@ def test_modify_column(engine_type, substr):
|
|||
assert not connection.execute.called
|
||||
|
||||
|
||||
def test_forgiving_add_column():
|
||||
def test_forgiving_add_column() -> None:
|
||||
"""Test that add column will continue if column exists."""
|
||||
engine = create_engine("sqlite://", poolclass=StaticPool)
|
||||
with Session(engine) as session:
|
||||
|
@ -413,7 +413,7 @@ def test_forgiving_add_column():
|
|||
)
|
||||
|
||||
|
||||
def test_forgiving_add_index():
|
||||
def test_forgiving_add_index() -> None:
|
||||
"""Test that add index will continue if index exists."""
|
||||
engine = create_engine("sqlite://", poolclass=StaticPool)
|
||||
db_schema.Base.metadata.create_all(engine)
|
||||
|
@ -454,7 +454,7 @@ class MockPyODBCProgrammingError(Exception):
|
|||
"""A mock pyodbc error."""
|
||||
|
||||
|
||||
def test_raise_if_exception_missing_str():
|
||||
def test_raise_if_exception_missing_str() -> None:
|
||||
"""Test we raise an exception if strings are not present."""
|
||||
programming_exc = ProgrammingError("select * from;", Mock(), Mock())
|
||||
programming_exc.__cause__ = MockPyODBCProgrammingError(
|
||||
|
@ -469,7 +469,7 @@ def test_raise_if_exception_missing_str():
|
|||
migration.raise_if_exception_missing_str(programming_exc, ["not present"])
|
||||
|
||||
|
||||
def test_raise_if_exception_missing_empty_cause_str():
|
||||
def test_raise_if_exception_missing_empty_cause_str() -> None:
|
||||
"""Test we raise an exception if strings are not present with an empty cause."""
|
||||
programming_exc = ProgrammingError("select * from;", Mock(), Mock())
|
||||
programming_exc.__cause__ = MockPyODBCProgrammingError()
|
||||
|
|
|
@ -28,7 +28,7 @@ from homeassistant.exceptions import InvalidEntityFormatError
|
|||
from homeassistant.util import dt, dt as dt_util
|
||||
|
||||
|
||||
def test_from_event_to_db_event():
|
||||
def test_from_event_to_db_event() -> None:
|
||||
"""Test converting event to db event."""
|
||||
event = ha.Event("test_event", {"some_data": 15})
|
||||
db_event = Events.from_event(event)
|
||||
|
@ -37,7 +37,7 @@ def test_from_event_to_db_event():
|
|||
assert event.as_dict() == db_event.to_native().as_dict()
|
||||
|
||||
|
||||
def test_from_event_to_db_state():
|
||||
def test_from_event_to_db_state() -> None:
|
||||
"""Test converting event to db state."""
|
||||
state = ha.State("sensor.temperature", "18")
|
||||
event = ha.Event(
|
||||
|
@ -48,7 +48,7 @@ def test_from_event_to_db_state():
|
|||
assert state.as_dict() == States.from_event(event).to_native().as_dict()
|
||||
|
||||
|
||||
def test_from_event_to_db_state_attributes():
|
||||
def test_from_event_to_db_state_attributes() -> None:
|
||||
"""Test converting event to db state attributes."""
|
||||
attrs = {"this_attr": True}
|
||||
state = ha.State("sensor.temperature", "18", attrs)
|
||||
|
@ -65,7 +65,7 @@ def test_from_event_to_db_state_attributes():
|
|||
assert db_attrs.to_native() == attrs
|
||||
|
||||
|
||||
def test_repr():
|
||||
def test_repr() -> None:
|
||||
"""Test converting event to db state repr."""
|
||||
attrs = {"this_attr": True}
|
||||
fixed_time = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC, microsecond=432432)
|
||||
|
@ -86,7 +86,7 @@ def test_repr():
|
|||
assert "2016-07-09 11:00:00+00:00" in repr(Events.from_event(event))
|
||||
|
||||
|
||||
def test_states_repr_without_timestamp():
|
||||
def test_states_repr_without_timestamp() -> None:
|
||||
"""Test repr for a state without last_updated_ts."""
|
||||
fixed_time = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC, microsecond=432432)
|
||||
states = States(
|
||||
|
@ -104,7 +104,7 @@ def test_states_repr_without_timestamp():
|
|||
assert "2016-07-09 11:00:00+00:00" in repr(states)
|
||||
|
||||
|
||||
def test_events_repr_without_timestamp():
|
||||
def test_events_repr_without_timestamp() -> None:
|
||||
"""Test repr for an event without time_fired_ts."""
|
||||
fixed_time = datetime(2016, 7, 9, 11, 0, 0, tzinfo=dt.UTC, microsecond=432432)
|
||||
events = Events(
|
||||
|
@ -129,7 +129,7 @@ def test_handling_broken_json_state_attributes(caplog):
|
|||
assert "Error converting row to state attributes" in caplog.text
|
||||
|
||||
|
||||
def test_from_event_to_delete_state():
|
||||
def test_from_event_to_delete_state() -> None:
|
||||
"""Test converting deleting state event to db state."""
|
||||
event = ha.Event(
|
||||
EVENT_STATE_CHANGED,
|
||||
|
@ -147,7 +147,7 @@ def test_from_event_to_delete_state():
|
|||
assert db_state.last_updated_ts == event.time_fired.timestamp()
|
||||
|
||||
|
||||
def test_entity_ids():
|
||||
def test_entity_ids() -> None:
|
||||
"""Test if entity ids helper method works."""
|
||||
engine = create_engine("sqlite://")
|
||||
Base.metadata.create_all(engine)
|
||||
|
@ -215,7 +215,7 @@ def test_entity_ids():
|
|||
assert run.entity_ids(in_run2) == ["sensor.humidity"]
|
||||
|
||||
|
||||
def test_states_from_native_invalid_entity_id():
|
||||
def test_states_from_native_invalid_entity_id() -> None:
|
||||
"""Test loading a state from an invalid entity ID."""
|
||||
state = States()
|
||||
state.entity_id = "test.invalid__id"
|
||||
|
|
|
@ -51,7 +51,7 @@ from tests.common import get_test_home_assistant, mock_registry
|
|||
ORIG_TZ = dt_util.DEFAULT_TIME_ZONE
|
||||
|
||||
|
||||
def test_converters_align_with_sensor():
|
||||
def test_converters_align_with_sensor() -> None:
|
||||
"""Ensure STATISTIC_UNIT_TO_UNIT_CONVERTER is aligned with UNIT_CONVERTERS."""
|
||||
for converter in UNIT_CONVERTERS.values():
|
||||
assert converter in STATISTIC_UNIT_TO_UNIT_CONVERTER.values()
|
||||
|
|
|
@ -844,7 +844,7 @@ async def test_write_lock_db(
|
|||
await hass.async_add_executor_job(_drop_table)
|
||||
|
||||
|
||||
def test_is_second_sunday():
|
||||
def test_is_second_sunday() -> None:
|
||||
"""Test we can find the second sunday of the month."""
|
||||
assert is_second_sunday(datetime(2022, 1, 9, 0, 0, 0, tzinfo=dt_util.UTC)) is True
|
||||
assert is_second_sunday(datetime(2022, 2, 13, 0, 0, 0, tzinfo=dt_util.UTC)) is True
|
||||
|
@ -855,7 +855,7 @@ def test_is_second_sunday():
|
|||
assert is_second_sunday(datetime(2022, 1, 10, 0, 0, 0, tzinfo=dt_util.UTC)) is False
|
||||
|
||||
|
||||
def test_build_mysqldb_conv():
|
||||
def test_build_mysqldb_conv() -> None:
|
||||
"""Test building the MySQLdb connect conv param."""
|
||||
mock_converters = Mock(conversions={"original": "preserved"})
|
||||
mock_constants = Mock(FIELD_TYPE=Mock(DATETIME="DATETIME"))
|
||||
|
|
|
@ -126,7 +126,7 @@ VOLUME_SENSOR_M3_ATTRIBUTES_TOTAL = {
|
|||
}
|
||||
|
||||
|
||||
def test_converters_align_with_sensor():
|
||||
def test_converters_align_with_sensor() -> None:
|
||||
"""Ensure UNIT_SCHEMA is aligned with sensor UNIT_CONVERTERS."""
|
||||
for converter in UNIT_CONVERTERS.values():
|
||||
assert converter.UNIT_CLASS in UNIT_SCHEMA.schema
|
||||
|
|
|
@ -912,7 +912,7 @@ async def test_options_configure_rfy_cover_device(hass):
|
|||
)
|
||||
|
||||
|
||||
def test_get_serial_by_id_no_dir():
|
||||
def test_get_serial_by_id_no_dir() -> None:
|
||||
"""Test serial by id conversion if there's no /dev/serial/by-id."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=False))
|
||||
p2 = patch("os.scandir")
|
||||
|
@ -923,7 +923,7 @@ def test_get_serial_by_id_no_dir():
|
|||
assert scan_mock.call_count == 0
|
||||
|
||||
|
||||
def test_get_serial_by_id():
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
|
|
@ -1176,7 +1176,7 @@ async def test_unit_conversion_priority_legacy_conversion_removed(
|
|||
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == original_unit
|
||||
|
||||
|
||||
def test_device_classes_aligned():
|
||||
def test_device_classes_aligned() -> None:
|
||||
"""Make sure all number device classes are also available in SensorDeviceClass."""
|
||||
|
||||
for device_class in NumberDeviceClass:
|
||||
|
|
|
@ -252,7 +252,7 @@ async def test_refresh_weather_forecast_retry(
|
|||
assert mock_get_forecast.call_count == 3
|
||||
|
||||
|
||||
def test_condition_class():
|
||||
def test_condition_class() -> None:
|
||||
"""Test condition class."""
|
||||
|
||||
def get_condition(index: int) -> str:
|
||||
|
|
|
@ -18,7 +18,7 @@ def mock_client():
|
|||
yield mock_client.return_value
|
||||
|
||||
|
||||
def test_invalid_config():
|
||||
def test_invalid_config() -> None:
|
||||
"""Test configuration with defaults."""
|
||||
config = {"statsd": {"host1": "host1"}}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ def test_config_valid_verify_ssl_bool(hass, mock_session_send):
|
|||
)
|
||||
|
||||
|
||||
def test_config_errors():
|
||||
def test_config_errors() -> None:
|
||||
"""Test for configuration errors."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
tomato.PLATFORM_SCHEMA(
|
||||
|
|
|
@ -141,7 +141,7 @@ def test_bad_response_returns_none(hass):
|
|||
assert _response_to_json("{(}") == {}
|
||||
|
||||
|
||||
def test_config_error():
|
||||
def test_config_error() -> None:
|
||||
"""Test for configuration errors."""
|
||||
with pytest.raises(vol.Invalid):
|
||||
PLATFORM_SCHEMA(
|
||||
|
|
|
@ -756,7 +756,7 @@ async def test_not_discovered_by_observer_before_started_on_docker(hass, docker)
|
|||
assert len(mock_config_flow.mock_calls) == 0
|
||||
|
||||
|
||||
def test_get_serial_by_id_no_dir():
|
||||
def test_get_serial_by_id_no_dir() -> None:
|
||||
"""Test serial by id conversion if there's no /dev/serial/by-id."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=False))
|
||||
p2 = patch("os.scandir")
|
||||
|
@ -767,7 +767,7 @@ def test_get_serial_by_id_no_dir():
|
|||
assert scan_mock.call_count == 0
|
||||
|
||||
|
||||
def test_get_serial_by_id():
|
||||
def test_get_serial_by_id() -> None:
|
||||
"""Test serial by id conversion."""
|
||||
p1 = patch("os.path.isdir", MagicMock(return_value=True))
|
||||
p2 = patch("os.scandir")
|
||||
|
@ -803,7 +803,7 @@ def test_get_serial_by_id():
|
|||
assert scan_mock.call_count == 2
|
||||
|
||||
|
||||
def test_human_readable_device_name():
|
||||
def test_human_readable_device_name() -> None:
|
||||
"""Test human readable device name includes the passed data."""
|
||||
name = usb.human_readable_device_name(
|
||||
"/dev/null",
|
||||
|
|
|
@ -74,7 +74,7 @@ def test_binary_sensor(hass: HomeAssistant):
|
|||
assert device_attrs[ATTR_SUBSCRIPTION_ID] == "123456"
|
||||
|
||||
|
||||
def test_invalid_sensor_config():
|
||||
def test_invalid_sensor_config() -> None:
|
||||
"""Test config type failures."""
|
||||
with pytest.raises(vol.Invalid): # No subs
|
||||
vultr.PLATFORM_SCHEMA({CONF_PLATFORM: base_vultr.DOMAIN})
|
||||
|
|
|
@ -93,7 +93,7 @@ def test_sensor(hass: HomeAssistant):
|
|||
assert tested == 5
|
||||
|
||||
|
||||
def test_invalid_sensor_config():
|
||||
def test_invalid_sensor_config() -> None:
|
||||
"""Test config type failures."""
|
||||
with pytest.raises(vol.Invalid): # No subscription
|
||||
vultr.PLATFORM_SCHEMA(
|
||||
|
|
|
@ -127,7 +127,7 @@ def test_turn_off(hass: HomeAssistant, hass_devices: list[vultr.VultrSwitch]):
|
|||
assert mock_halt.call_count == 1
|
||||
|
||||
|
||||
def test_invalid_switch_config():
|
||||
def test_invalid_switch_config() -> None:
|
||||
"""Test config type failures."""
|
||||
with pytest.raises(vol.Invalid): # No subscription
|
||||
vultr.PLATFORM_SCHEMA({CONF_PLATFORM: base_vultr.DOMAIN})
|
||||
|
|
|
@ -319,7 +319,7 @@ async def test_out_channel_config(
|
|||
assert cluster.configure_reporting.call_count == 0
|
||||
|
||||
|
||||
def test_channel_registry():
|
||||
def test_channel_registry() -> None:
|
||||
"""Test ZIGBEE Channel Registry."""
|
||||
for cluster_id, channel in registries.ZIGBEE_CHANNEL_REGISTRY.items():
|
||||
assert isinstance(cluster_id, int)
|
||||
|
|
|
@ -267,7 +267,7 @@ async def device_climate_zonnsmart(device_climate_mock):
|
|||
)
|
||||
|
||||
|
||||
def test_sequence_mappings():
|
||||
def test_sequence_mappings() -> None:
|
||||
"""Test correct mapping between control sequence -> HVAC Mode -> Sysmode."""
|
||||
|
||||
for hvac_modes in SEQ_OF_OPERATION.values():
|
||||
|
|
|
@ -1037,7 +1037,7 @@ async def test_hardware_invalid_data(hass, data):
|
|||
assert result["reason"] == "invalid_hardware_data"
|
||||
|
||||
|
||||
def test_allow_overwrite_ezsp_ieee():
|
||||
def test_allow_overwrite_ezsp_ieee() -> None:
|
||||
"""Test modifying the backup to allow bellows to override the IEEE address."""
|
||||
backup = zigpy.backups.NetworkBackup()
|
||||
new_backup = radio_manager._allow_overwrite_ezsp_ieee(backup)
|
||||
|
@ -1046,7 +1046,7 @@ def test_allow_overwrite_ezsp_ieee():
|
|||
assert new_backup.network_info.stack_specific["ezsp"][EZSP_OVERWRITE_EUI64] is True
|
||||
|
||||
|
||||
def test_prevent_overwrite_ezsp_ieee():
|
||||
def test_prevent_overwrite_ezsp_ieee() -> None:
|
||||
"""Test modifying the backup to prevent bellows from overriding the IEEE address."""
|
||||
backup = zigpy.backups.NetworkBackup()
|
||||
backup.network_info.stack_specific["ezsp"] = {EZSP_OVERWRITE_EUI64: True}
|
||||
|
@ -1342,7 +1342,7 @@ async def test_formation_strategy_restore_manual_backup_invalid_upload(
|
|||
assert result3["errors"]["base"] == "invalid_backup_json"
|
||||
|
||||
|
||||
def test_format_backup_choice():
|
||||
def test_format_backup_choice() -> None:
|
||||
"""Test formatting zigpy NetworkBackup objects."""
|
||||
backup = zigpy.backups.NetworkBackup()
|
||||
backup.network_info.pan_id = zigpy.types.PanId(0x1234)
|
||||
|
|
|
@ -264,7 +264,7 @@ def test_discover_by_device_type(device_type, component, hit):
|
|||
assert ep_channels.async_new_entity.call_args[0][1] == mock.sentinel.entity_cls
|
||||
|
||||
|
||||
def test_discover_by_device_type_override():
|
||||
def test_discover_by_device_type_override() -> None:
|
||||
"""Test entity discovery by device type overriding."""
|
||||
|
||||
ep_channels = mock.MagicMock(spec_set=zha_channels.ChannelPool)
|
||||
|
@ -290,7 +290,7 @@ def test_discover_by_device_type_override():
|
|||
assert ep_channels.async_new_entity.call_args[0][1] == mock.sentinel.entity_cls
|
||||
|
||||
|
||||
def test_discover_probe_single_cluster():
|
||||
def test_discover_probe_single_cluster() -> None:
|
||||
"""Test entity discovery by single cluster."""
|
||||
|
||||
ep_channels = mock.MagicMock(spec_set=zha_channels.ChannelPool)
|
||||
|
@ -424,7 +424,7 @@ def _test_single_input_cluster_device_class(probe_mock):
|
|||
assert call[0][1] == ch
|
||||
|
||||
|
||||
def test_single_input_cluster_device_class_by_cluster_class():
|
||||
def test_single_input_cluster_device_class_by_cluster_class() -> None:
|
||||
"""Test SINGLE_INPUT_CLUSTER_DEVICE_CLASS matching by cluster id or class."""
|
||||
mock_reg = {
|
||||
zigpy.zcl.clusters.closures.DoorLock.cluster_id: Platform.LOCK,
|
||||
|
|
|
@ -5,7 +5,7 @@ import voluptuous as vol
|
|||
from homeassistant.components.zwave_js.config_validation import boolean
|
||||
|
||||
|
||||
def test_boolean_validation():
|
||||
def test_boolean_validation() -> None:
|
||||
"""Test boolean config validator."""
|
||||
# test bool
|
||||
assert boolean(True)
|
||||
|
|
|
@ -99,7 +99,7 @@ class MockStorageCollection(collection.StorageCollection):
|
|||
return {**data, **update_data}
|
||||
|
||||
|
||||
def test_id_manager():
|
||||
def test_id_manager() -> None:
|
||||
"""Test the ID manager."""
|
||||
id_manager = collection.IDManager()
|
||||
assert not id_manager.has_id("some_id")
|
||||
|
|
|
@ -88,7 +88,7 @@ class MockOAuth2Implementation(config_entry_oauth2_flow.AbstractOAuth2Implementa
|
|||
raise NotImplementedError()
|
||||
|
||||
|
||||
def test_inherit_enforces_domain_set():
|
||||
def test_inherit_enforces_domain_set() -> None:
|
||||
"""Test we enforce setting DOMAIN."""
|
||||
|
||||
class TestFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
||||
|
|
|
@ -14,7 +14,7 @@ import homeassistant
|
|||
from homeassistant.helpers import config_validation as cv, selector, template
|
||||
|
||||
|
||||
def test_boolean():
|
||||
def test_boolean() -> None:
|
||||
"""Test boolean validation."""
|
||||
schema = vol.Schema(cv.boolean)
|
||||
|
||||
|
@ -39,7 +39,7 @@ def test_boolean():
|
|||
assert not schema(value)
|
||||
|
||||
|
||||
def test_latitude():
|
||||
def test_latitude() -> None:
|
||||
"""Test latitude validation."""
|
||||
schema = vol.Schema(cv.latitude)
|
||||
|
||||
|
@ -51,7 +51,7 @@ def test_latitude():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_longitude():
|
||||
def test_longitude() -> None:
|
||||
"""Test longitude validation."""
|
||||
schema = vol.Schema(cv.longitude)
|
||||
|
||||
|
@ -63,7 +63,7 @@ def test_longitude():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_port():
|
||||
def test_port() -> None:
|
||||
"""Test TCP/UDP network port."""
|
||||
schema = vol.Schema(cv.port)
|
||||
|
||||
|
@ -75,7 +75,7 @@ def test_port():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_isfile():
|
||||
def test_isfile() -> None:
|
||||
"""Validate that the value is an existing file."""
|
||||
schema = vol.Schema(cv.isfile)
|
||||
|
||||
|
@ -94,7 +94,7 @@ def test_isfile():
|
|||
schema("test.txt")
|
||||
|
||||
|
||||
def test_url():
|
||||
def test_url() -> None:
|
||||
"""Test URL."""
|
||||
schema = vol.Schema(cv.url)
|
||||
|
||||
|
@ -120,7 +120,7 @@ def test_url():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_url_no_path():
|
||||
def test_url_no_path() -> None:
|
||||
"""Test URL."""
|
||||
schema = vol.Schema(cv.url_no_path)
|
||||
|
||||
|
@ -139,7 +139,7 @@ def test_url_no_path():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_platform_config():
|
||||
def test_platform_config() -> None:
|
||||
"""Test platform config validation."""
|
||||
options = ({}, {"hello": "world"})
|
||||
for value in options:
|
||||
|
@ -151,7 +151,7 @@ def test_platform_config():
|
|||
cv.PLATFORM_SCHEMA_BASE(value)
|
||||
|
||||
|
||||
def test_ensure_list():
|
||||
def test_ensure_list() -> None:
|
||||
"""Test ensure_list."""
|
||||
schema = vol.Schema(cv.ensure_list)
|
||||
assert [] == schema(None)
|
||||
|
@ -162,7 +162,7 @@ def test_ensure_list():
|
|||
assert [{"1": "2"}] == schema({"1": "2"})
|
||||
|
||||
|
||||
def test_entity_id():
|
||||
def test_entity_id() -> None:
|
||||
"""Test entity ID validation."""
|
||||
schema = vol.Schema(cv.entity_id)
|
||||
|
||||
|
@ -195,7 +195,7 @@ def test_entity_ids(validator):
|
|||
assert schema("sensor.LIGHT, light.kitchen ") == ["sensor.light", "light.kitchen"]
|
||||
|
||||
|
||||
def test_entity_ids_or_uuids():
|
||||
def test_entity_ids_or_uuids() -> None:
|
||||
"""Test entity ID validation."""
|
||||
schema = vol.Schema(cv.entity_ids_or_uuids)
|
||||
|
||||
|
@ -221,7 +221,7 @@ def test_entity_ids_or_uuids():
|
|||
assert schema(f"{valid_uuid}, {valid_uuid2} ") == [valid_uuid, valid_uuid2]
|
||||
|
||||
|
||||
def test_entity_domain():
|
||||
def test_entity_domain() -> None:
|
||||
"""Test entity domain validation."""
|
||||
schema = vol.Schema(cv.entity_domain("sensor"))
|
||||
|
||||
|
@ -246,7 +246,7 @@ def test_entity_domain():
|
|||
assert schema("binary_sensor.LIGHT") == "binary_sensor.light"
|
||||
|
||||
|
||||
def test_entities_domain():
|
||||
def test_entities_domain() -> None:
|
||||
"""Test entities domain validation."""
|
||||
schema = vol.Schema(cv.entities_domain("sensor"))
|
||||
|
||||
|
@ -270,7 +270,7 @@ def test_entities_domain():
|
|||
assert schema(["sensor.light", "SENSOR.demo"]) == ["sensor.light", "sensor.demo"]
|
||||
|
||||
|
||||
def test_ensure_list_csv():
|
||||
def test_ensure_list_csv() -> None:
|
||||
"""Test ensure_list_csv."""
|
||||
schema = vol.Schema(cv.ensure_list_csv)
|
||||
|
||||
|
@ -281,7 +281,7 @@ def test_ensure_list_csv():
|
|||
assert schema("string1, string2 ") == ["string1", "string2"]
|
||||
|
||||
|
||||
def test_event_schema():
|
||||
def test_event_schema() -> None:
|
||||
"""Test event_schema validation."""
|
||||
options = (
|
||||
{},
|
||||
|
@ -301,7 +301,7 @@ def test_event_schema():
|
|||
cv.EVENT_SCHEMA(value)
|
||||
|
||||
|
||||
def test_icon():
|
||||
def test_icon() -> None:
|
||||
"""Test icon validation."""
|
||||
schema = vol.Schema(cv.icon)
|
||||
|
||||
|
@ -313,7 +313,7 @@ def test_icon():
|
|||
schema("custom:prefix")
|
||||
|
||||
|
||||
def test_time_period():
|
||||
def test_time_period() -> None:
|
||||
"""Test time_period validation."""
|
||||
schema = vol.Schema(cv.time_period)
|
||||
|
||||
|
@ -362,12 +362,12 @@ def test_time_period():
|
|||
assert schema(value) == result
|
||||
|
||||
|
||||
def test_remove_falsy():
|
||||
def test_remove_falsy() -> None:
|
||||
"""Test remove falsy."""
|
||||
assert cv.remove_falsy([0, None, 1, "1", {}, [], ""]) == [1, "1"]
|
||||
|
||||
|
||||
def test_service():
|
||||
def test_service() -> None:
|
||||
"""Test service validation."""
|
||||
schema = vol.Schema(cv.service)
|
||||
|
||||
|
@ -377,7 +377,7 @@ def test_service():
|
|||
schema("homeassistant.turn_on")
|
||||
|
||||
|
||||
def test_service_schema():
|
||||
def test_service_schema() -> None:
|
||||
"""Test service_schema validation."""
|
||||
options = (
|
||||
{},
|
||||
|
@ -421,7 +421,7 @@ def test_service_schema():
|
|||
}
|
||||
|
||||
|
||||
def test_entity_service_schema():
|
||||
def test_entity_service_schema() -> None:
|
||||
"""Test make_entity_service_schema validation."""
|
||||
schema = cv.make_entity_service_schema(
|
||||
{vol.Required("required"): cv.positive_int, vol.Optional("optional"): cv.string}
|
||||
|
@ -460,7 +460,7 @@ def test_entity_service_schema():
|
|||
assert "metadata" not in validated
|
||||
|
||||
|
||||
def test_entity_service_schema_with_metadata():
|
||||
def test_entity_service_schema_with_metadata() -> None:
|
||||
"""Test make_entity_service_schema with overridden metadata key."""
|
||||
schema = cv.make_entity_service_schema({vol.Required("metadata"): cv.positive_int})
|
||||
|
||||
|
@ -475,7 +475,7 @@ def test_entity_service_schema_with_metadata():
|
|||
assert "metadata" in validated
|
||||
|
||||
|
||||
def test_slug():
|
||||
def test_slug() -> None:
|
||||
"""Test slug validation."""
|
||||
schema = vol.Schema(cv.slug)
|
||||
|
||||
|
@ -517,7 +517,7 @@ def test_string(hass):
|
|||
assert schema(result) == text
|
||||
|
||||
|
||||
def test_string_with_no_html():
|
||||
def test_string_with_no_html() -> None:
|
||||
"""Test string with no html validation."""
|
||||
schema = vol.Schema(cv.string_with_no_html)
|
||||
|
||||
|
@ -537,7 +537,7 @@ def test_string_with_no_html():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_temperature_unit():
|
||||
def test_temperature_unit() -> None:
|
||||
"""Test temperature unit validation."""
|
||||
schema = vol.Schema(cv.temperature_unit)
|
||||
|
||||
|
@ -548,7 +548,7 @@ def test_temperature_unit():
|
|||
schema("F")
|
||||
|
||||
|
||||
def test_x10_address():
|
||||
def test_x10_address() -> None:
|
||||
"""Test x10 addr validator."""
|
||||
schema = vol.Schema(cv.x10_address)
|
||||
with pytest.raises(vol.Invalid):
|
||||
|
@ -560,7 +560,7 @@ def test_x10_address():
|
|||
schema("C11")
|
||||
|
||||
|
||||
def test_template():
|
||||
def test_template() -> None:
|
||||
"""Test template validator."""
|
||||
schema = vol.Schema(cv.template)
|
||||
|
||||
|
@ -578,7 +578,7 @@ def test_template():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_dynamic_template():
|
||||
def test_dynamic_template() -> None:
|
||||
"""Test dynamic template validator."""
|
||||
schema = vol.Schema(cv.dynamic_template)
|
||||
|
||||
|
@ -601,7 +601,7 @@ def test_dynamic_template():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_template_complex():
|
||||
def test_template_complex() -> None:
|
||||
"""Test template_complex validator."""
|
||||
schema = vol.Schema(cv.template_complex)
|
||||
|
||||
|
@ -635,7 +635,7 @@ def test_template_complex():
|
|||
assert schema(value) == value
|
||||
|
||||
|
||||
def test_time_zone():
|
||||
def test_time_zone() -> None:
|
||||
"""Test time zone validation."""
|
||||
schema = vol.Schema(cv.time_zone)
|
||||
|
||||
|
@ -646,7 +646,7 @@ def test_time_zone():
|
|||
schema("UTC")
|
||||
|
||||
|
||||
def test_date():
|
||||
def test_date() -> None:
|
||||
"""Test date validation."""
|
||||
schema = vol.Schema(cv.date)
|
||||
|
||||
|
@ -658,7 +658,7 @@ def test_date():
|
|||
schema("2016-11-23")
|
||||
|
||||
|
||||
def test_time():
|
||||
def test_time() -> None:
|
||||
"""Test date validation."""
|
||||
schema = vol.Schema(cv.time)
|
||||
|
||||
|
@ -671,7 +671,7 @@ def test_time():
|
|||
schema("23:42")
|
||||
|
||||
|
||||
def test_datetime():
|
||||
def test_datetime() -> None:
|
||||
"""Test date time validation."""
|
||||
schema = vol.Schema(cv.datetime)
|
||||
for value in [date.today(), "Wrong DateTime"]:
|
||||
|
@ -682,7 +682,7 @@ def test_datetime():
|
|||
schema("2016-11-23T18:59:08")
|
||||
|
||||
|
||||
def test_multi_select():
|
||||
def test_multi_select() -> None:
|
||||
"""Test multi select validation.
|
||||
|
||||
Expected behavior:
|
||||
|
@ -698,7 +698,7 @@ def test_multi_select():
|
|||
schema(["robban", "paulus"])
|
||||
|
||||
|
||||
def test_multi_select_in_serializer():
|
||||
def test_multi_select_in_serializer() -> None:
|
||||
"""Test multi_select with custom_serializer."""
|
||||
assert cv.custom_serializer(cv.multi_select({"paulus": "Paulus"})) == {
|
||||
"type": "multi_select",
|
||||
|
@ -706,21 +706,21 @@ def test_multi_select_in_serializer():
|
|||
}
|
||||
|
||||
|
||||
def test_boolean_in_serializer():
|
||||
def test_boolean_in_serializer() -> None:
|
||||
"""Test boolean with custom_serializer."""
|
||||
assert cv.custom_serializer(cv.boolean) == {
|
||||
"type": "boolean",
|
||||
}
|
||||
|
||||
|
||||
def test_string_in_serializer():
|
||||
def test_string_in_serializer() -> None:
|
||||
"""Test string with custom_serializer."""
|
||||
assert cv.custom_serializer(cv.string) == {
|
||||
"type": "string",
|
||||
}
|
||||
|
||||
|
||||
def test_selector_in_serializer():
|
||||
def test_selector_in_serializer() -> None:
|
||||
"""Test selector with custom_serializer."""
|
||||
assert cv.custom_serializer(selector.selector({"text": {}})) == {
|
||||
"selector": {
|
||||
|
@ -731,7 +731,7 @@ def test_selector_in_serializer():
|
|||
}
|
||||
|
||||
|
||||
def test_positive_time_period_dict_in_serializer():
|
||||
def test_positive_time_period_dict_in_serializer() -> None:
|
||||
"""Test positive_time_period_dict with custom_serializer."""
|
||||
assert cv.custom_serializer(cv.positive_time_period_dict) == {
|
||||
"type": "positive_time_period_dict",
|
||||
|
@ -941,7 +941,7 @@ def test_deprecated_with_replacement_key_and_default(caplog, schema):
|
|||
assert {"jupiter": True} == output
|
||||
|
||||
|
||||
def test_deprecated_cant_find_module():
|
||||
def test_deprecated_cant_find_module() -> None:
|
||||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
# This used to raise.
|
||||
|
@ -1049,7 +1049,7 @@ def test_deprecated_logger_without_config_attributes(caplog):
|
|||
assert len(caplog.records) == 0
|
||||
|
||||
|
||||
def test_key_dependency():
|
||||
def test_key_dependency() -> None:
|
||||
"""Test key_dependency validator."""
|
||||
schema = vol.Schema(cv.key_dependency("beer", "soda"))
|
||||
|
||||
|
@ -1063,7 +1063,7 @@ def test_key_dependency():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_has_at_most_one_key():
|
||||
def test_has_at_most_one_key() -> None:
|
||||
"""Test has_at_most_one_key validator."""
|
||||
schema = vol.Schema(cv.has_at_most_one_key("beer", "soda"))
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ def test_has_at_most_one_key():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_has_at_least_one_key():
|
||||
def test_has_at_least_one_key() -> None:
|
||||
"""Test has_at_least_one_key validator."""
|
||||
schema = vol.Schema(cv.has_at_least_one_key("beer", "soda"))
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ def test_has_at_least_one_key():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_enum():
|
||||
def test_enum() -> None:
|
||||
"""Test enum validator."""
|
||||
|
||||
class TestEnum(enum.Enum):
|
||||
|
@ -1117,7 +1117,7 @@ def test_socket_timeout(): # pylint: disable=invalid-name
|
|||
assert schema(1) == 1.0
|
||||
|
||||
|
||||
def test_matches_regex():
|
||||
def test_matches_regex() -> None:
|
||||
"""Test matches_regex validator."""
|
||||
schema = vol.Schema(cv.matches_regex(".*uiae.*"))
|
||||
|
||||
|
@ -1131,7 +1131,7 @@ def test_matches_regex():
|
|||
assert schema(test_str) == test_str
|
||||
|
||||
|
||||
def test_is_regex():
|
||||
def test_is_regex() -> None:
|
||||
"""Test the is_regex validator."""
|
||||
schema = vol.Schema(cv.is_regex)
|
||||
|
||||
|
@ -1145,7 +1145,7 @@ def test_is_regex():
|
|||
schema(valid_re)
|
||||
|
||||
|
||||
def test_comp_entity_ids():
|
||||
def test_comp_entity_ids() -> None:
|
||||
"""Test config validation for component entity IDs."""
|
||||
schema = vol.Schema(cv.comp_entity_ids)
|
||||
|
||||
|
@ -1186,7 +1186,7 @@ def test_uuid4_hex(caplog):
|
|||
assert schema(_hex.upper()) == _hex
|
||||
|
||||
|
||||
def test_key_value_schemas():
|
||||
def test_key_value_schemas() -> None:
|
||||
"""Test key value schemas."""
|
||||
schema = vol.Schema(
|
||||
cv.key_value_schemas(
|
||||
|
@ -1222,7 +1222,7 @@ def test_key_value_schemas():
|
|||
schema({"mode": mode, "data": data})
|
||||
|
||||
|
||||
def test_key_value_schemas_with_default():
|
||||
def test_key_value_schemas_with_default() -> None:
|
||||
"""Test key value schemas."""
|
||||
schema = vol.Schema(
|
||||
cv.key_value_schemas(
|
||||
|
@ -1293,7 +1293,7 @@ def test_script(caplog):
|
|||
assert msg in str(excinfo.value)
|
||||
|
||||
|
||||
def test_whitespace():
|
||||
def test_whitespace() -> None:
|
||||
"""Test whitespace validation."""
|
||||
schema = vol.Schema(cv.whitespace)
|
||||
|
||||
|
@ -1314,7 +1314,7 @@ def test_whitespace():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_currency():
|
||||
def test_currency() -> None:
|
||||
"""Test currency validator."""
|
||||
schema = vol.Schema(cv.currency)
|
||||
|
||||
|
@ -1329,7 +1329,7 @@ def test_currency():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_historic_currency():
|
||||
def test_historic_currency() -> None:
|
||||
"""Test historic currency validator."""
|
||||
schema = vol.Schema(cv.historic_currency)
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ def test_historic_currency():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_country():
|
||||
def test_country() -> None:
|
||||
"""Test country validator."""
|
||||
schema = vol.Schema(cv.country)
|
||||
|
||||
|
@ -1353,7 +1353,7 @@ def test_country():
|
|||
assert schema(value)
|
||||
|
||||
|
||||
def test_language():
|
||||
def test_language() -> None:
|
||||
"""Test language validator."""
|
||||
schema = vol.Schema(cv.language)
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@ from tests.common import (
|
|||
)
|
||||
|
||||
|
||||
def test_generate_entity_id_requires_hass_or_ids():
|
||||
def test_generate_entity_id_requires_hass_or_ids() -> None:
|
||||
"""Ensure we require at least hass or current ids."""
|
||||
with pytest.raises(ValueError):
|
||||
entity.generate_entity_id("test.{}", "hello world")
|
||||
|
||||
|
||||
def test_generate_entity_id_given_keys():
|
||||
def test_generate_entity_id_given_keys() -> None:
|
||||
"""Test generating an entity id given current ids."""
|
||||
assert (
|
||||
entity.generate_entity_id(
|
||||
|
|
|
@ -1290,7 +1290,7 @@ async def test_resolve_entity_ids(hass, registry):
|
|||
er.async_validate_entity_ids(registry, ["unknown_uuid"])
|
||||
|
||||
|
||||
def test_entity_registry_items():
|
||||
def test_entity_registry_items() -> None:
|
||||
"""Test the EntityRegistryItems container."""
|
||||
entities = er.EntityRegistryItems()
|
||||
assert entities.get_entity_id(("a", "b", "c")) is None
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.helpers.entity_values import EntityValues as EV
|
|||
ent = "test.test"
|
||||
|
||||
|
||||
def test_override_single_value():
|
||||
def test_override_single_value() -> None:
|
||||
"""Test values with exact match."""
|
||||
store = EV({ent: {"key": "value"}})
|
||||
assert store.get(ent) == {"key": "value"}
|
||||
|
@ -15,25 +15,25 @@ def test_override_single_value():
|
|||
assert len(store._cache) == 1
|
||||
|
||||
|
||||
def test_override_by_domain():
|
||||
def test_override_by_domain() -> None:
|
||||
"""Test values with domain match."""
|
||||
store = EV(domain={"test": {"key": "value"}})
|
||||
assert store.get(ent) == {"key": "value"}
|
||||
|
||||
|
||||
def test_override_by_glob():
|
||||
def test_override_by_glob() -> None:
|
||||
"""Test values with glob match."""
|
||||
store = EV(glob={"test.?e*": {"key": "value"}})
|
||||
assert store.get(ent) == {"key": "value"}
|
||||
|
||||
|
||||
def test_glob_overrules_domain():
|
||||
def test_glob_overrules_domain() -> None:
|
||||
"""Test domain overrules glob match."""
|
||||
store = EV(domain={"test": {"key": "domain"}}, glob={"test.?e*": {"key": "glob"}})
|
||||
assert store.get(ent) == {"key": "glob"}
|
||||
|
||||
|
||||
def test_exact_overrules_domain():
|
||||
def test_exact_overrules_domain() -> None:
|
||||
"""Test exact overrules domain match."""
|
||||
store = EV(
|
||||
exact={"test.test": {"key": "exact"}},
|
||||
|
@ -43,7 +43,7 @@ def test_exact_overrules_domain():
|
|||
assert store.get(ent) == {"key": "exact"}
|
||||
|
||||
|
||||
def test_merging_values():
|
||||
def test_merging_values() -> None:
|
||||
"""Test merging glob, domain and exact configs."""
|
||||
store = EV(
|
||||
exact={"test.test": {"exact_key": "exact"}},
|
||||
|
@ -57,7 +57,7 @@ def test_merging_values():
|
|||
}
|
||||
|
||||
|
||||
def test_glob_order():
|
||||
def test_glob_order() -> None:
|
||||
"""Test merging glob, domain and exact configs."""
|
||||
glob = OrderedDict()
|
||||
glob["test.*est"] = {"value": "first"}
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.helpers.entityfilter import (
|
|||
)
|
||||
|
||||
|
||||
def test_no_filters_case_1():
|
||||
def test_no_filters_case_1() -> None:
|
||||
"""If include and exclude not included, pass everything."""
|
||||
incl_dom = {}
|
||||
incl_ent = {}
|
||||
|
@ -19,7 +19,7 @@ def test_no_filters_case_1():
|
|||
assert testfilter(value)
|
||||
|
||||
|
||||
def test_includes_only_case_2():
|
||||
def test_includes_only_case_2() -> None:
|
||||
"""If include specified, only pass if specified (Case 2)."""
|
||||
incl_dom = {"light", "sensor"}
|
||||
incl_ent = {"binary_sensor.working"}
|
||||
|
@ -34,7 +34,7 @@ def test_includes_only_case_2():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_includes_only_with_glob_case_2():
|
||||
def test_includes_only_with_glob_case_2() -> None:
|
||||
"""If include specified, only pass if specified (Case 2)."""
|
||||
incl_dom = {"light", "sensor"}
|
||||
incl_glob = {"cover.*_window"}
|
||||
|
@ -55,7 +55,7 @@ def test_includes_only_with_glob_case_2():
|
|||
assert testfilter("cover.garage_door") is False
|
||||
|
||||
|
||||
def test_excludes_only_case_3():
|
||||
def test_excludes_only_case_3() -> None:
|
||||
"""If exclude specified, pass all but specified (Case 3)."""
|
||||
incl_dom = {}
|
||||
incl_ent = {}
|
||||
|
@ -70,7 +70,7 @@ def test_excludes_only_case_3():
|
|||
assert testfilter("sun.sun") is True
|
||||
|
||||
|
||||
def test_excludes_only_with_glob_case_3():
|
||||
def test_excludes_only_with_glob_case_3() -> None:
|
||||
"""If exclude specified, pass all but specified (Case 3)."""
|
||||
incl_dom = {}
|
||||
incl_glob = {}
|
||||
|
@ -91,7 +91,7 @@ def test_excludes_only_with_glob_case_3():
|
|||
assert testfilter("cover.garage_door")
|
||||
|
||||
|
||||
def test_with_include_domain_case4():
|
||||
def test_with_include_domain_case4() -> None:
|
||||
"""Test case 4 - include and exclude specified, with included domain."""
|
||||
incl_dom = {"light", "sensor"}
|
||||
incl_ent = {"binary_sensor.working"}
|
||||
|
@ -108,7 +108,7 @@ def test_with_include_domain_case4():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_with_include_domain_exclude_glob_case4():
|
||||
def test_with_include_domain_exclude_glob_case4() -> None:
|
||||
"""Test case 4 - include and exclude specified, with included domain but excluded by glob."""
|
||||
incl_dom = {"light", "sensor"}
|
||||
incl_ent = {"binary_sensor.working"}
|
||||
|
@ -130,7 +130,7 @@ def test_with_include_domain_exclude_glob_case4():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_with_include_glob_case4():
|
||||
def test_with_include_glob_case4() -> None:
|
||||
"""Test case 4 - include and exclude specified, with included glob."""
|
||||
incl_dom = {}
|
||||
incl_glob = {"light.*", "sensor.*"}
|
||||
|
@ -151,7 +151,7 @@ def test_with_include_glob_case4():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_with_include_domain_glob_filtering_case4():
|
||||
def test_with_include_domain_glob_filtering_case4() -> None:
|
||||
"""Test case 4 - include and exclude specified, both have domains and globs."""
|
||||
incl_dom = {"light"}
|
||||
incl_glob = {"*working"}
|
||||
|
@ -173,7 +173,7 @@ def test_with_include_domain_glob_filtering_case4():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_with_include_domain_glob_filtering_case4a_include_strong():
|
||||
def test_with_include_domain_glob_filtering_case4a_include_strong() -> None:
|
||||
"""Test case 4 - include and exclude specified, both have domains and globs, and a specifically included entity."""
|
||||
incl_dom = {"light"}
|
||||
incl_glob = {"*working"}
|
||||
|
@ -196,7 +196,7 @@ def test_with_include_domain_glob_filtering_case4a_include_strong():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_with_include_glob_filtering_case4a_include_strong():
|
||||
def test_with_include_glob_filtering_case4a_include_strong() -> None:
|
||||
"""Test case 4 - include and exclude specified, both have globs, and a specifically included entity."""
|
||||
incl_dom = {}
|
||||
incl_glob = {"*working"}
|
||||
|
@ -220,7 +220,7 @@ def test_with_include_glob_filtering_case4a_include_strong():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_exclude_domain_case5():
|
||||
def test_exclude_domain_case5() -> None:
|
||||
"""Test case 5 - include and exclude specified, with excluded domain."""
|
||||
incl_dom = {}
|
||||
incl_ent = {"binary_sensor.working"}
|
||||
|
@ -237,7 +237,7 @@ def test_exclude_domain_case5():
|
|||
assert testfilter("sun.sun") is True
|
||||
|
||||
|
||||
def test_exclude_glob_case5():
|
||||
def test_exclude_glob_case5() -> None:
|
||||
"""Test case 5 - include and exclude specified, with excluded glob."""
|
||||
incl_dom = {}
|
||||
incl_glob = {}
|
||||
|
@ -258,7 +258,7 @@ def test_exclude_glob_case5():
|
|||
assert testfilter("sun.sun") is True
|
||||
|
||||
|
||||
def test_exclude_glob_case5_include_strong():
|
||||
def test_exclude_glob_case5_include_strong() -> None:
|
||||
"""Test case 5 - include and exclude specified, with excluded glob, and a specifically included entity."""
|
||||
incl_dom = {}
|
||||
incl_glob = {}
|
||||
|
@ -279,7 +279,7 @@ def test_exclude_glob_case5_include_strong():
|
|||
assert testfilter("sun.sun") is True
|
||||
|
||||
|
||||
def test_no_domain_case6():
|
||||
def test_no_domain_case6() -> None:
|
||||
"""Test case 6 - include and exclude specified, with no domains."""
|
||||
incl_dom = {}
|
||||
incl_ent = {"binary_sensor.working"}
|
||||
|
@ -296,7 +296,7 @@ def test_no_domain_case6():
|
|||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_filter_schema_empty():
|
||||
def test_filter_schema_empty() -> None:
|
||||
"""Test filter schema."""
|
||||
conf = {}
|
||||
filt = FILTER_SCHEMA(conf)
|
||||
|
@ -314,7 +314,7 @@ def test_filter_schema_empty():
|
|||
assert filt.empty_filter
|
||||
|
||||
|
||||
def test_filter_schema():
|
||||
def test_filter_schema() -> None:
|
||||
"""Test filter schema."""
|
||||
conf = {
|
||||
"include_domains": ["light"],
|
||||
|
@ -328,7 +328,7 @@ def test_filter_schema():
|
|||
assert not filt.empty_filter
|
||||
|
||||
|
||||
def test_filter_schema_with_globs():
|
||||
def test_filter_schema_with_globs() -> None:
|
||||
"""Test filter schema with glob options."""
|
||||
conf = {
|
||||
"include_domains": ["light"],
|
||||
|
@ -343,7 +343,7 @@ def test_filter_schema_with_globs():
|
|||
assert not filt.empty_filter
|
||||
|
||||
|
||||
def test_filter_schema_include_exclude():
|
||||
def test_filter_schema_include_exclude() -> None:
|
||||
"""Test the include exclude filter schema."""
|
||||
conf = {
|
||||
"include": {
|
||||
|
@ -369,7 +369,7 @@ def test_filter_schema_include_exclude():
|
|||
assert not filt.empty_filter
|
||||
|
||||
|
||||
def test_exlictly_included():
|
||||
def test_exlictly_included() -> None:
|
||||
"""Test if an entity is explicitly included."""
|
||||
conf = {
|
||||
"include": {
|
||||
|
@ -395,7 +395,7 @@ def test_exlictly_included():
|
|||
assert filt.explicitly_excluded("light.kitchen")
|
||||
|
||||
|
||||
def test_complex_include_exclude_filter():
|
||||
def test_complex_include_exclude_filter() -> None:
|
||||
"""Test a complex include exclude filter."""
|
||||
conf = {
|
||||
"include": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Test Home Assistant icon util methods."""
|
||||
|
||||
|
||||
def test_battery_icon():
|
||||
def test_battery_icon() -> None:
|
||||
"""Test icon generator for battery sensor."""
|
||||
from homeassistant.helpers.icon import icon_for_battery_level
|
||||
|
||||
|
@ -46,7 +46,7 @@ def test_battery_icon():
|
|||
assert iconbase + postfix_charging == icon_for_battery_level(level, True)
|
||||
|
||||
|
||||
def test_signal_icon():
|
||||
def test_signal_icon() -> None:
|
||||
"""Test icon generator for signal sensor."""
|
||||
from homeassistant.helpers.icon import icon_for_signal_level
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from collections import OrderedDict
|
|||
from homeassistant import helpers
|
||||
|
||||
|
||||
def test_extract_domain_configs():
|
||||
def test_extract_domain_configs() -> None:
|
||||
"""Test the extraction of domain configuration."""
|
||||
config = {
|
||||
"zone": None,
|
||||
|
@ -20,7 +20,7 @@ def test_extract_domain_configs():
|
|||
)
|
||||
|
||||
|
||||
def test_config_per_platform():
|
||||
def test_config_per_platform() -> None:
|
||||
"""Test config per platform method."""
|
||||
config = OrderedDict(
|
||||
[
|
||||
|
|
|
@ -140,7 +140,7 @@ async def test_match_device_area(hass):
|
|||
) == [state1]
|
||||
|
||||
|
||||
def test_async_validate_slots():
|
||||
def test_async_validate_slots() -> None:
|
||||
"""Test async_validate_slots of IntentHandler."""
|
||||
handler1 = MockIntentHandler({vol.Required("name"): cv.string})
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ def test_extended_json_encoder(hass):
|
|||
assert ha_json_enc.default(o) == {"__type": str(type(o)), "repr": repr(o)}
|
||||
|
||||
|
||||
def test_json_dumps_sorted():
|
||||
def test_json_dumps_sorted() -> None:
|
||||
"""Test the json dumps sorted function."""
|
||||
data = {"c": 3, "a": 1, "b": 2}
|
||||
assert json_dumps_sorted(data) == json.dumps(
|
||||
|
@ -84,7 +84,7 @@ def test_json_dumps_sorted():
|
|||
)
|
||||
|
||||
|
||||
def test_json_dumps_float_subclass():
|
||||
def test_json_dumps_float_subclass() -> None:
|
||||
"""Test the json dumps a float subclass."""
|
||||
|
||||
class FloatSubclass(float):
|
||||
|
@ -93,7 +93,7 @@ def test_json_dumps_float_subclass():
|
|||
assert json_dumps({"c": FloatSubclass(1.2)}) == '{"c":1.2}'
|
||||
|
||||
|
||||
def test_json_dumps_tuple_subclass():
|
||||
def test_json_dumps_tuple_subclass() -> None:
|
||||
"""Test the json dumps a tuple subclass."""
|
||||
|
||||
tt = time.struct_time((1999, 3, 17, 32, 44, 55, 2, 76, 0))
|
||||
|
@ -101,7 +101,7 @@ def test_json_dumps_tuple_subclass():
|
|||
assert json_dumps(tt) == "[1999,3,17,32,44,55,2,76,0]"
|
||||
|
||||
|
||||
def test_json_dumps_named_tuple_subclass():
|
||||
def test_json_dumps_named_tuple_subclass() -> None:
|
||||
"""Test the json dumps a tuple subclass."""
|
||||
|
||||
class NamedTupleSubclass(NamedTuple):
|
||||
|
@ -114,14 +114,14 @@ def test_json_dumps_named_tuple_subclass():
|
|||
assert json_dumps(nts) == '["a"]'
|
||||
|
||||
|
||||
def test_json_dumps_rgb_color_subclass():
|
||||
def test_json_dumps_rgb_color_subclass() -> None:
|
||||
"""Test the json dumps of RGBColor."""
|
||||
rgb = RGBColor(4, 2, 1)
|
||||
|
||||
assert json_dumps(rgb) == "[4,2,1]"
|
||||
|
||||
|
||||
def test_json_bytes_strip_null():
|
||||
def test_json_bytes_strip_null() -> None:
|
||||
"""Test stripping nul from strings."""
|
||||
|
||||
assert json_bytes_strip_null("\0") == b'""'
|
||||
|
|
|
@ -4,13 +4,13 @@ from homeassistant.core import State
|
|||
from homeassistant.helpers import location
|
||||
|
||||
|
||||
def test_has_location_with_invalid_states():
|
||||
def test_has_location_with_invalid_states() -> None:
|
||||
"""Set up the tests."""
|
||||
for state in (None, 1, "hello", object):
|
||||
assert not location.has_location(state)
|
||||
|
||||
|
||||
def test_has_location_with_states_with_invalid_locations():
|
||||
def test_has_location_with_states_with_invalid_locations() -> None:
|
||||
"""Set up the tests."""
|
||||
state = State(
|
||||
"hello.world", "invalid", {ATTR_LATITUDE: "no number", ATTR_LONGITUDE: 123.12}
|
||||
|
@ -18,7 +18,7 @@ def test_has_location_with_states_with_invalid_locations():
|
|||
assert not location.has_location(state)
|
||||
|
||||
|
||||
def test_has_location_with_states_with_valid_location():
|
||||
def test_has_location_with_states_with_valid_location() -> None:
|
||||
"""Set up the tests."""
|
||||
state = State(
|
||||
"hello.world", "invalid", {ATTR_LATITUDE: 123.12, ATTR_LONGITUDE: 123.12}
|
||||
|
@ -26,7 +26,7 @@ def test_has_location_with_states_with_valid_location():
|
|||
assert location.has_location(state)
|
||||
|
||||
|
||||
def test_closest_with_no_states_with_location():
|
||||
def test_closest_with_no_states_with_location() -> None:
|
||||
"""Set up the tests."""
|
||||
state = State("light.test", "on")
|
||||
state2 = State(
|
||||
|
@ -37,7 +37,7 @@ def test_closest_with_no_states_with_location():
|
|||
assert location.closest(123.45, 123.45, [state, state2, state3]) is None
|
||||
|
||||
|
||||
def test_closest_returns_closest():
|
||||
def test_closest_returns_closest() -> None:
|
||||
"""Test ."""
|
||||
state = State("light.test", "on", {ATTR_LATITUDE: 124.45, ATTR_LONGITUDE: 124.45})
|
||||
state2 = State("light.test", "on", {ATTR_LATITUDE: 125.45, ATTR_LONGITUDE: 125.45})
|
||||
|
|
|
@ -20,7 +20,7 @@ def mock_config_flows():
|
|||
yield flows
|
||||
|
||||
|
||||
def test_recursive_flatten():
|
||||
def test_recursive_flatten() -> None:
|
||||
"""Test the flatten function."""
|
||||
data = {"parent1": {"child1": "data1", "child2": "data2"}, "parent2": "data3"}
|
||||
|
||||
|
|
|
@ -134,14 +134,14 @@ async def test_ensure_existing_files_is_not_overwritten(hass):
|
|||
assert content == ""
|
||||
|
||||
|
||||
def test_load_yaml_config_converts_empty_files_to_dict():
|
||||
def test_load_yaml_config_converts_empty_files_to_dict() -> None:
|
||||
"""Test that loading an empty file returns an empty dict."""
|
||||
create_file(YAML_PATH)
|
||||
|
||||
assert isinstance(config_util.load_yaml_config_file(YAML_PATH), dict)
|
||||
|
||||
|
||||
def test_load_yaml_config_raises_error_if_not_dict():
|
||||
def test_load_yaml_config_raises_error_if_not_dict() -> None:
|
||||
"""Test error raised when YAML file is not a dict."""
|
||||
with open(YAML_PATH, "w") as fp:
|
||||
fp.write("5")
|
||||
|
@ -150,7 +150,7 @@ def test_load_yaml_config_raises_error_if_not_dict():
|
|||
config_util.load_yaml_config_file(YAML_PATH)
|
||||
|
||||
|
||||
def test_load_yaml_config_raises_error_if_malformed_yaml():
|
||||
def test_load_yaml_config_raises_error_if_malformed_yaml() -> None:
|
||||
"""Test error raised if invalid YAML."""
|
||||
with open(YAML_PATH, "w") as fp:
|
||||
fp.write(":-")
|
||||
|
@ -159,7 +159,7 @@ def test_load_yaml_config_raises_error_if_malformed_yaml():
|
|||
config_util.load_yaml_config_file(YAML_PATH)
|
||||
|
||||
|
||||
def test_load_yaml_config_raises_error_if_unsafe_yaml():
|
||||
def test_load_yaml_config_raises_error_if_unsafe_yaml() -> None:
|
||||
"""Test error raised if unsafe YAML."""
|
||||
with open(YAML_PATH, "w") as fp:
|
||||
fp.write("- !!python/object/apply:os.system []")
|
||||
|
@ -179,7 +179,7 @@ def test_load_yaml_config_raises_error_if_unsafe_yaml():
|
|||
assert len(system_mock.mock_calls) == 1
|
||||
|
||||
|
||||
def test_load_yaml_config_preserves_key_order():
|
||||
def test_load_yaml_config_preserves_key_order() -> None:
|
||||
"""Test removal of library."""
|
||||
with open(YAML_PATH, "w") as fp:
|
||||
fp.write("hello: 2\n")
|
||||
|
@ -201,7 +201,7 @@ async def test_create_default_config_returns_none_if_write_error(hass):
|
|||
assert mock_print.called
|
||||
|
||||
|
||||
def test_core_config_schema():
|
||||
def test_core_config_schema() -> None:
|
||||
"""Test core config schema."""
|
||||
for value in (
|
||||
{CONF_UNIT_SYSTEM: "K"},
|
||||
|
@ -249,7 +249,7 @@ def test_core_config_schema_internal_external_warning(caplog):
|
|||
assert "Invalid internal_url set" in caplog.text
|
||||
|
||||
|
||||
def test_customize_dict_schema():
|
||||
def test_customize_dict_schema() -> None:
|
||||
"""Test basic customize config validation."""
|
||||
values = ({ATTR_FRIENDLY_NAME: None}, {ATTR_ASSUMED_STATE: "2"})
|
||||
|
||||
|
@ -262,7 +262,7 @@ def test_customize_dict_schema():
|
|||
) == {ATTR_FRIENDLY_NAME: "2", ATTR_ASSUMED_STATE: False}
|
||||
|
||||
|
||||
def test_customize_glob_is_ordered():
|
||||
def test_customize_glob_is_ordered() -> None:
|
||||
"""Test that customize_glob preserves order."""
|
||||
conf = config_util.CORE_CONFIG_SCHEMA({"customize_glob": OrderedDict()})
|
||||
assert isinstance(conf["customize_glob"], OrderedDict)
|
||||
|
|
|
@ -48,7 +48,7 @@ from .common import async_capture_events, async_mock_service
|
|||
PST = dt_util.get_time_zone("America/Los_Angeles")
|
||||
|
||||
|
||||
def test_split_entity_id():
|
||||
def test_split_entity_id() -> None:
|
||||
"""Test split_entity_id."""
|
||||
assert ha.split_entity_id("domain.object_id") == ("domain", "object_id")
|
||||
with pytest.raises(ValueError):
|
||||
|
@ -63,7 +63,7 @@ def test_split_entity_id():
|
|||
ha.split_entity_id(".empty_domain")
|
||||
|
||||
|
||||
def test_async_add_hass_job_schedule_callback():
|
||||
def test_async_add_hass_job_schedule_callback() -> None:
|
||||
"""Test that we schedule coroutines and add jobs to the job pool."""
|
||||
hass = MagicMock()
|
||||
job = MagicMock()
|
||||
|
@ -74,7 +74,7 @@ def test_async_add_hass_job_schedule_callback():
|
|||
assert len(hass.add_job.mock_calls) == 0
|
||||
|
||||
|
||||
def test_async_add_hass_job_schedule_partial_callback():
|
||||
def test_async_add_hass_job_schedule_partial_callback() -> None:
|
||||
"""Test that we schedule partial coros and add jobs to the job pool."""
|
||||
hass = MagicMock()
|
||||
job = MagicMock()
|
||||
|
@ -114,7 +114,7 @@ def test_async_add_hass_job_schedule_partial_coroutinefunction(event_loop):
|
|||
assert len(hass.add_job.mock_calls) == 0
|
||||
|
||||
|
||||
def test_async_add_job_add_hass_threaded_job_to_pool():
|
||||
def test_async_add_job_add_hass_threaded_job_to_pool() -> None:
|
||||
"""Test that we schedule coroutines and add jobs to the job pool."""
|
||||
hass = MagicMock()
|
||||
|
||||
|
@ -140,7 +140,7 @@ def test_async_create_task_schedule_coroutine(event_loop):
|
|||
assert len(hass.add_job.mock_calls) == 0
|
||||
|
||||
|
||||
def test_async_run_hass_job_calls_callback():
|
||||
def test_async_run_hass_job_calls_callback() -> None:
|
||||
"""Test that the callback annotation is respected."""
|
||||
hass = MagicMock()
|
||||
calls = []
|
||||
|
@ -153,7 +153,7 @@ def test_async_run_hass_job_calls_callback():
|
|||
assert len(hass.async_add_job.mock_calls) == 0
|
||||
|
||||
|
||||
def test_async_run_hass_job_delegates_non_async():
|
||||
def test_async_run_hass_job_delegates_non_async() -> None:
|
||||
"""Test that the callback annotation is respected."""
|
||||
hass = MagicMock()
|
||||
calls = []
|
||||
|
@ -322,7 +322,7 @@ async def test_add_job_with_none(hass):
|
|||
hass.async_add_job(None, "test_arg")
|
||||
|
||||
|
||||
def test_event_eq():
|
||||
def test_event_eq() -> None:
|
||||
"""Test events."""
|
||||
now = dt_util.utcnow()
|
||||
data = {"some": "attr"}
|
||||
|
@ -334,7 +334,7 @@ def test_event_eq():
|
|||
assert event1.as_dict() == event2.as_dict()
|
||||
|
||||
|
||||
def test_event_repr():
|
||||
def test_event_repr() -> None:
|
||||
"""Test that Event repr method works."""
|
||||
assert str(ha.Event("TestEvent")) == "<Event TestEvent[L]>"
|
||||
|
||||
|
@ -344,7 +344,7 @@ def test_event_repr():
|
|||
)
|
||||
|
||||
|
||||
def test_event_as_dict():
|
||||
def test_event_as_dict() -> None:
|
||||
"""Test an Event as dictionary."""
|
||||
event_type = "some_type"
|
||||
now = dt_util.utcnow()
|
||||
|
@ -367,7 +367,7 @@ def test_event_as_dict():
|
|||
assert event.as_dict() == expected
|
||||
|
||||
|
||||
def test_state_as_dict():
|
||||
def test_state_as_dict() -> None:
|
||||
"""Test a State as dictionary."""
|
||||
last_time = datetime(1984, 12, 8, 12, 0, 0)
|
||||
state = ha.State(
|
||||
|
@ -399,7 +399,7 @@ def test_state_as_dict():
|
|||
assert state.as_dict() is as_dict_1
|
||||
|
||||
|
||||
def test_state_as_compressed_state():
|
||||
def test_state_as_compressed_state() -> None:
|
||||
"""Test a State as compressed state."""
|
||||
last_time = datetime(1984, 12, 8, 12, 0, 0, tzinfo=dt_util.UTC)
|
||||
state = ha.State(
|
||||
|
@ -424,7 +424,7 @@ def test_state_as_compressed_state():
|
|||
assert state.as_compressed_state() is as_compressed_state
|
||||
|
||||
|
||||
def test_state_as_compressed_state_unique_last_updated():
|
||||
def test_state_as_compressed_state_unique_last_updated() -> None:
|
||||
"""Test a State as compressed state where last_changed is not last_updated."""
|
||||
last_changed = datetime(1984, 12, 8, 11, 0, 0, tzinfo=dt_util.UTC)
|
||||
last_updated = datetime(1984, 12, 8, 12, 0, 0, tzinfo=dt_util.UTC)
|
||||
|
@ -648,7 +648,7 @@ async def test_eventbus_max_length_exceeded(hass):
|
|||
assert exc_info.value.value == long_evt_name
|
||||
|
||||
|
||||
def test_state_init():
|
||||
def test_state_init() -> None:
|
||||
"""Test state.init."""
|
||||
with pytest.raises(InvalidEntityFormatError):
|
||||
ha.State("invalid_entity_format", "test_state")
|
||||
|
@ -657,38 +657,38 @@ def test_state_init():
|
|||
ha.State("domain.long_state", "t" * 256)
|
||||
|
||||
|
||||
def test_state_domain():
|
||||
def test_state_domain() -> None:
|
||||
"""Test domain."""
|
||||
state = ha.State("some_domain.hello", "world")
|
||||
assert state.domain == "some_domain"
|
||||
|
||||
|
||||
def test_state_object_id():
|
||||
def test_state_object_id() -> None:
|
||||
"""Test object ID."""
|
||||
state = ha.State("domain.hello", "world")
|
||||
assert state.object_id == "hello"
|
||||
|
||||
|
||||
def test_state_name_if_no_friendly_name_attr():
|
||||
def test_state_name_if_no_friendly_name_attr() -> None:
|
||||
"""Test if there is no friendly name."""
|
||||
state = ha.State("domain.hello_world", "world")
|
||||
assert state.name == "hello world"
|
||||
|
||||
|
||||
def test_state_name_if_friendly_name_attr():
|
||||
def test_state_name_if_friendly_name_attr() -> None:
|
||||
"""Test if there is a friendly name."""
|
||||
name = "Some Unique Name"
|
||||
state = ha.State("domain.hello_world", "world", {ATTR_FRIENDLY_NAME: name})
|
||||
assert state.name == name
|
||||
|
||||
|
||||
def test_state_dict_conversion():
|
||||
def test_state_dict_conversion() -> None:
|
||||
"""Test conversion of dict."""
|
||||
state = ha.State("domain.hello", "world", {"some": "attr"})
|
||||
assert state.as_dict() == ha.State.from_dict(state.as_dict()).as_dict()
|
||||
|
||||
|
||||
def test_state_dict_conversion_with_wrong_data():
|
||||
def test_state_dict_conversion_with_wrong_data() -> None:
|
||||
"""Test conversion with wrong data."""
|
||||
assert ha.State.from_dict(None) is None
|
||||
assert ha.State.from_dict({"state": "yes"}) is None
|
||||
|
@ -705,7 +705,7 @@ def test_state_dict_conversion_with_wrong_data():
|
|||
assert wrong_context.context.id == "123"
|
||||
|
||||
|
||||
def test_state_repr():
|
||||
def test_state_repr() -> None:
|
||||
"""Test state.repr."""
|
||||
assert (
|
||||
str(ha.State("happy.happy", "on", last_changed=datetime(1984, 12, 8, 12, 0, 0)))
|
||||
|
@ -813,7 +813,7 @@ async def test_statemachine_force_update(hass):
|
|||
assert len(events) == 1
|
||||
|
||||
|
||||
def test_service_call_repr():
|
||||
def test_service_call_repr() -> None:
|
||||
"""Test ServiceCall repr."""
|
||||
call = ha.ServiceCall("homeassistant", "start")
|
||||
assert str(call) == f"<ServiceCall homeassistant.start (c:{call.context.id})>"
|
||||
|
@ -1216,7 +1216,7 @@ async def test_service_call_event_contains_original_data(hass):
|
|||
assert calls[0].context is context
|
||||
|
||||
|
||||
def test_context():
|
||||
def test_context() -> None:
|
||||
"""Test context init."""
|
||||
c = ha.Context()
|
||||
assert c.user_id is None
|
||||
|
@ -1290,7 +1290,7 @@ async def test_cancel_service_task(hass, cancel_call):
|
|||
assert service_cancelled
|
||||
|
||||
|
||||
def test_valid_entity_id():
|
||||
def test_valid_entity_id() -> None:
|
||||
"""Test valid entity ID."""
|
||||
for invalid in [
|
||||
"_light.kitchen",
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest_socket
|
|||
from homeassistant.core import async_get_hass
|
||||
|
||||
|
||||
def test_sockets_disabled():
|
||||
def test_sockets_disabled() -> None:
|
||||
"""Test we can't open sockets."""
|
||||
with pytest.raises(pytest_socket.SocketBlockedError):
|
||||
socket.socket()
|
||||
|
|
|
@ -28,7 +28,7 @@ async def test_request_post_query() -> None:
|
|||
assert request.query == {"get": "true"}
|
||||
|
||||
|
||||
def test_serialize_text():
|
||||
def test_serialize_text() -> None:
|
||||
"""Test serializing a text response."""
|
||||
response = web.Response(status=201, text="Hello")
|
||||
assert aiohttp.serialize_response(response) == {
|
||||
|
@ -38,7 +38,7 @@ def test_serialize_text():
|
|||
}
|
||||
|
||||
|
||||
def test_serialize_body_str():
|
||||
def test_serialize_body_str() -> None:
|
||||
"""Test serializing a response with a str as body."""
|
||||
response = web.Response(status=201, body="Hello")
|
||||
assert aiohttp.serialize_response(response) == {
|
||||
|
@ -48,7 +48,7 @@ def test_serialize_body_str():
|
|||
}
|
||||
|
||||
|
||||
def test_serialize_body_None():
|
||||
def test_serialize_body_None() -> None:
|
||||
"""Test serializing a response with a str as body."""
|
||||
response = web.Response(status=201, body=None)
|
||||
assert aiohttp.serialize_response(response) == {
|
||||
|
@ -58,7 +58,7 @@ def test_serialize_body_None():
|
|||
}
|
||||
|
||||
|
||||
def test_serialize_body_bytes():
|
||||
def test_serialize_body_bytes() -> None:
|
||||
"""Test serializing a response with a str as body."""
|
||||
response = web.Response(status=201, body=b"Hello")
|
||||
assert aiohttp.serialize_response(response) == {
|
||||
|
@ -68,7 +68,7 @@ def test_serialize_body_bytes():
|
|||
}
|
||||
|
||||
|
||||
def test_serialize_json():
|
||||
def test_serialize_json() -> None:
|
||||
"""Test serializing a JSON response."""
|
||||
response = web.json_response({"how": "what"})
|
||||
assert aiohttp.serialize_response(response) == {
|
||||
|
|
|
@ -180,7 +180,7 @@ def test_check_loop_sync(caplog):
|
|||
assert "Detected blocking call inside the event loop" not in caplog.text
|
||||
|
||||
|
||||
def test_protect_loop_sync():
|
||||
def test_protect_loop_sync() -> None:
|
||||
"""Test protect_loop calls check_loop."""
|
||||
func = Mock()
|
||||
with patch("homeassistant.util.async_.check_loop") as mock_check_loop:
|
||||
|
|
|
@ -32,7 +32,7 @@ GAMUT_INVALID_4 = color_util.GamutType(
|
|||
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def test_color_RGB_to_xy_brightness():
|
||||
def test_color_RGB_to_xy_brightness() -> None:
|
||||
"""Test color_RGB_to_xy_brightness."""
|
||||
assert color_util.color_RGB_to_xy_brightness(0, 0, 0) == (0, 0, 0)
|
||||
assert color_util.color_RGB_to_xy_brightness(255, 255, 255) == (0.323, 0.329, 255)
|
||||
|
@ -56,7 +56,7 @@ def test_color_RGB_to_xy_brightness():
|
|||
assert color_util.color_RGB_to_xy_brightness(0, 0, 255, GAMUT) == (0.138, 0.08, 12)
|
||||
|
||||
|
||||
def test_color_RGB_to_xy():
|
||||
def test_color_RGB_to_xy() -> None:
|
||||
"""Test color_RGB_to_xy."""
|
||||
assert color_util.color_RGB_to_xy(0, 0, 0) == (0, 0)
|
||||
assert color_util.color_RGB_to_xy(255, 255, 255) == (0.323, 0.329)
|
||||
|
@ -76,7 +76,7 @@ def test_color_RGB_to_xy():
|
|||
assert color_util.color_RGB_to_xy(255, 0, 0, GAMUT) == (0.7, 0.299)
|
||||
|
||||
|
||||
def test_color_xy_brightness_to_RGB():
|
||||
def test_color_xy_brightness_to_RGB() -> None:
|
||||
"""Test color_xy_brightness_to_RGB."""
|
||||
assert color_util.color_xy_brightness_to_RGB(1, 1, 0) == (0, 0, 0)
|
||||
|
||||
|
@ -97,7 +97,7 @@ def test_color_xy_brightness_to_RGB():
|
|||
assert color_util.color_xy_brightness_to_RGB(0, 0, 255, GAMUT) == (9, 85, 255)
|
||||
|
||||
|
||||
def test_color_xy_to_RGB():
|
||||
def test_color_xy_to_RGB() -> None:
|
||||
"""Test color_xy_to_RGB."""
|
||||
assert color_util.color_xy_to_RGB(0.35, 0.35) == (255, 243, 222)
|
||||
|
||||
|
@ -114,7 +114,7 @@ def test_color_xy_to_RGB():
|
|||
assert color_util.color_xy_to_RGB(0, 0, GAMUT) == (9, 85, 255)
|
||||
|
||||
|
||||
def test_color_RGB_to_hsv():
|
||||
def test_color_RGB_to_hsv() -> None:
|
||||
"""Test color_RGB_to_hsv."""
|
||||
assert color_util.color_RGB_to_hsv(0, 0, 0) == (0, 0, 0)
|
||||
|
||||
|
@ -127,7 +127,7 @@ def test_color_RGB_to_hsv():
|
|||
assert color_util.color_RGB_to_hsv(255, 0, 0) == (0, 100, 100)
|
||||
|
||||
|
||||
def test_color_hsv_to_RGB():
|
||||
def test_color_hsv_to_RGB() -> None:
|
||||
"""Test color_hsv_to_RGB."""
|
||||
assert color_util.color_hsv_to_RGB(0, 0, 0) == (0, 0, 0)
|
||||
|
||||
|
@ -140,7 +140,7 @@ def test_color_hsv_to_RGB():
|
|||
assert color_util.color_hsv_to_RGB(0, 100, 100) == (255, 0, 0)
|
||||
|
||||
|
||||
def test_color_hsb_to_RGB():
|
||||
def test_color_hsb_to_RGB() -> None:
|
||||
"""Test color_hsb_to_RGB."""
|
||||
assert color_util.color_hsb_to_RGB(0, 0, 0) == (0, 0, 0)
|
||||
|
||||
|
@ -153,7 +153,7 @@ def test_color_hsb_to_RGB():
|
|||
assert color_util.color_hsb_to_RGB(0, 1.0, 1.0) == (255, 0, 0)
|
||||
|
||||
|
||||
def test_color_xy_to_hs():
|
||||
def test_color_xy_to_hs() -> None:
|
||||
"""Test color_xy_to_hs."""
|
||||
assert color_util.color_xy_to_hs(1, 1) == (47.294, 100)
|
||||
|
||||
|
@ -172,7 +172,7 @@ def test_color_xy_to_hs():
|
|||
assert color_util.color_xy_to_hs(0, 0, GAMUT) == (221.463, 96.471)
|
||||
|
||||
|
||||
def test_color_hs_to_xy():
|
||||
def test_color_hs_to_xy() -> None:
|
||||
"""Test color_hs_to_xy."""
|
||||
assert color_util.color_hs_to_xy(180, 100) == (0.151, 0.343)
|
||||
|
||||
|
@ -195,7 +195,7 @@ def test_color_hs_to_xy():
|
|||
assert color_util.color_hs_to_xy(360, 100, GAMUT) == (0.7, 0.299)
|
||||
|
||||
|
||||
def test_rgb_hex_to_rgb_list():
|
||||
def test_rgb_hex_to_rgb_list() -> None:
|
||||
"""Test rgb_hex_to_rgb_list."""
|
||||
assert [255, 255, 255] == color_util.rgb_hex_to_rgb_list("ffffff")
|
||||
|
||||
|
@ -210,7 +210,7 @@ def test_rgb_hex_to_rgb_list():
|
|||
assert [51, 153, 255, 0] == color_util.rgb_hex_to_rgb_list("3399ff00")
|
||||
|
||||
|
||||
def test_color_name_to_rgb_valid_name():
|
||||
def test_color_name_to_rgb_valid_name() -> None:
|
||||
"""Test color_name_to_rgb."""
|
||||
assert color_util.color_name_to_rgb("red") == (255, 0, 0)
|
||||
|
||||
|
@ -227,13 +227,13 @@ def test_color_name_to_rgb_valid_name():
|
|||
assert color_util.color_name_to_rgb("darkslate blue") == (72, 61, 139)
|
||||
|
||||
|
||||
def test_color_name_to_rgb_unknown_name_raises_value_error():
|
||||
def test_color_name_to_rgb_unknown_name_raises_value_error() -> None:
|
||||
"""Test color_name_to_rgb."""
|
||||
with pytest.raises(ValueError):
|
||||
color_util.color_name_to_rgb("not a color")
|
||||
|
||||
|
||||
def test_color_rgb_to_rgbw():
|
||||
def test_color_rgb_to_rgbw() -> None:
|
||||
"""Test color_rgb_to_rgbw."""
|
||||
assert color_util.color_rgb_to_rgbw(0, 0, 0) == (0, 0, 0, 0)
|
||||
|
||||
|
@ -252,7 +252,7 @@ def test_color_rgb_to_rgbw():
|
|||
assert color_util.color_rgb_to_rgbw(127, 127, 127) == (0, 0, 0, 127)
|
||||
|
||||
|
||||
def test_color_rgbw_to_rgb():
|
||||
def test_color_rgbw_to_rgb() -> None:
|
||||
"""Test color_rgbw_to_rgb."""
|
||||
assert color_util.color_rgbw_to_rgb(0, 0, 0, 0) == (0, 0, 0)
|
||||
|
||||
|
@ -271,7 +271,7 @@ def test_color_rgbw_to_rgb():
|
|||
assert color_util.color_rgbw_to_rgb(0, 0, 0, 127) == (127, 127, 127)
|
||||
|
||||
|
||||
def test_color_rgb_to_hex():
|
||||
def test_color_rgb_to_hex() -> None:
|
||||
"""Test color_rgb_to_hex."""
|
||||
assert color_util.color_rgb_to_hex(255, 255, 255) == "ffffff"
|
||||
assert color_util.color_rgb_to_hex(0, 0, 0) == "000000"
|
||||
|
@ -279,7 +279,7 @@ def test_color_rgb_to_hex():
|
|||
assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == "ff4400"
|
||||
|
||||
|
||||
def test_match_max_scale():
|
||||
def test_match_max_scale() -> None:
|
||||
"""Test match_max_scale."""
|
||||
match_max_scale = color_util.match_max_scale
|
||||
assert match_max_scale((255, 255, 255), (255, 255, 255)) == (255, 255, 255)
|
||||
|
@ -293,7 +293,7 @@ def test_match_max_scale():
|
|||
assert match_max_scale((10, 20, 30, 128), (100, 200, 333)) == (38, 77, 128)
|
||||
|
||||
|
||||
def test_gamut():
|
||||
def test_gamut() -> None:
|
||||
"""Test gamut functions."""
|
||||
assert color_util.check_valid_gamut(GAMUT)
|
||||
assert not color_util.check_valid_gamut(GAMUT_INVALID_1)
|
||||
|
@ -302,7 +302,7 @@ def test_gamut():
|
|||
assert not color_util.check_valid_gamut(GAMUT_INVALID_4)
|
||||
|
||||
|
||||
def test_color_temperature_mired_to_kelvin():
|
||||
def test_color_temperature_mired_to_kelvin() -> None:
|
||||
"""Test color_temperature_mired_to_kelvin."""
|
||||
assert color_util.color_temperature_mired_to_kelvin(40) == 25000
|
||||
assert color_util.color_temperature_mired_to_kelvin(200) == 5000
|
||||
|
@ -310,7 +310,7 @@ def test_color_temperature_mired_to_kelvin():
|
|||
assert color_util.color_temperature_mired_to_kelvin(0)
|
||||
|
||||
|
||||
def test_color_temperature_kelvin_to_mired():
|
||||
def test_color_temperature_kelvin_to_mired() -> None:
|
||||
"""Test color_temperature_kelvin_to_mired."""
|
||||
assert color_util.color_temperature_kelvin_to_mired(25000) == 40
|
||||
assert color_util.color_temperature_kelvin_to_mired(5000) == 200
|
||||
|
@ -318,21 +318,21 @@ def test_color_temperature_kelvin_to_mired():
|
|||
assert color_util.color_temperature_kelvin_to_mired(0)
|
||||
|
||||
|
||||
def test_returns_same_value_for_any_two_temperatures_below_1000():
|
||||
def test_returns_same_value_for_any_two_temperatures_below_1000() -> None:
|
||||
"""Function should return same value for 999 Kelvin and 0 Kelvin."""
|
||||
rgb_1 = color_util.color_temperature_to_rgb(999)
|
||||
rgb_2 = color_util.color_temperature_to_rgb(0)
|
||||
assert rgb_1 == rgb_2
|
||||
|
||||
|
||||
def test_returns_same_value_for_any_two_temperatures_above_40000():
|
||||
def test_returns_same_value_for_any_two_temperatures_above_40000() -> None:
|
||||
"""Function should return same value for 40001K and 999999K."""
|
||||
rgb_1 = color_util.color_temperature_to_rgb(40001)
|
||||
rgb_2 = color_util.color_temperature_to_rgb(999999)
|
||||
assert rgb_1 == rgb_2
|
||||
|
||||
|
||||
def test_should_return_pure_white_at_6600():
|
||||
def test_should_return_pure_white_at_6600() -> None:
|
||||
"""Function should return red=255, blue=255, green=255 when given 6600K.
|
||||
|
||||
6600K is considered "pure white" light.
|
||||
|
@ -343,21 +343,21 @@ def test_should_return_pure_white_at_6600():
|
|||
assert rgb == (255, 255, 255)
|
||||
|
||||
|
||||
def test_color_above_6600_should_have_more_blue_than_red_or_green():
|
||||
def test_color_above_6600_should_have_more_blue_than_red_or_green() -> None:
|
||||
"""Function should return a higher blue value for blue-ish light."""
|
||||
rgb = color_util.color_temperature_to_rgb(6700)
|
||||
assert rgb[2] > rgb[1]
|
||||
assert rgb[2] > rgb[0]
|
||||
|
||||
|
||||
def test_color_below_6600_should_have_more_red_than_blue_or_green():
|
||||
def test_color_below_6600_should_have_more_red_than_blue_or_green() -> None:
|
||||
"""Function should return a higher red value for red-ish light."""
|
||||
rgb = color_util.color_temperature_to_rgb(6500)
|
||||
assert rgb[0] > rgb[1]
|
||||
assert rgb[0] > rgb[2]
|
||||
|
||||
|
||||
def test_get_color_in_voluptuous():
|
||||
def test_get_color_in_voluptuous() -> None:
|
||||
"""Test using the get method in color validation."""
|
||||
schema = vol.Schema(color_util.color_name_to_rgb)
|
||||
|
||||
|
@ -367,7 +367,7 @@ def test_get_color_in_voluptuous():
|
|||
assert schema("red") == (255, 0, 0)
|
||||
|
||||
|
||||
def test_color_rgb_to_rgbww():
|
||||
def test_color_rgb_to_rgbww() -> None:
|
||||
"""Test color_rgb_to_rgbww conversions."""
|
||||
# Light with mid point at ~4600K (warm white) -> output compensated by adding blue
|
||||
assert color_util.color_rgb_to_rgbww(255, 255, 255, 2702, 6493) == (
|
||||
|
@ -413,7 +413,7 @@ def test_color_rgb_to_rgbww():
|
|||
)
|
||||
|
||||
|
||||
def test_color_rgbww_to_rgb():
|
||||
def test_color_rgbww_to_rgb() -> None:
|
||||
"""Test color_rgbww_to_rgb conversions."""
|
||||
assert color_util.color_rgbww_to_rgb(0, 54, 98, 255, 255, 2702, 6493) == (
|
||||
255,
|
||||
|
@ -449,7 +449,7 @@ def test_color_rgbww_to_rgb():
|
|||
)
|
||||
|
||||
|
||||
def test_color_temperature_to_rgbww():
|
||||
def test_color_temperature_to_rgbww() -> None:
|
||||
"""Test color temp to warm, cold conversion.
|
||||
|
||||
Temperature values must be in mireds
|
||||
|
@ -502,7 +502,7 @@ def test_color_temperature_to_rgbww():
|
|||
)
|
||||
|
||||
|
||||
def test_rgbww_to_color_temperature():
|
||||
def test_rgbww_to_color_temperature() -> None:
|
||||
"""Test rgbww conversion to color temp.
|
||||
|
||||
Temperature values must be in mireds
|
||||
|
@ -542,7 +542,7 @@ def test_rgbww_to_color_temperature():
|
|||
)
|
||||
|
||||
|
||||
def test_white_levels_to_color_temperature():
|
||||
def test_white_levels_to_color_temperature() -> None:
|
||||
"""Test warm, cold conversion to color temp.
|
||||
|
||||
Temperature values must be in mireds
|
||||
|
|
|
@ -25,7 +25,7 @@ def test_raise_deprecation_warning(caplog: pytest.LogCaptureFixture) -> None:
|
|||
assert "use unit_conversion.DistanceConverter instead" in caplog.text
|
||||
|
||||
|
||||
def test_convert_same_unit():
|
||||
def test_convert_same_unit() -> None:
|
||||
"""Test conversion from any unit to same unit."""
|
||||
assert distance_util.convert(5, LENGTH_KILOMETERS, LENGTH_KILOMETERS) == 5
|
||||
assert distance_util.convert(2, LENGTH_METERS, LENGTH_METERS) == 2
|
||||
|
@ -37,7 +37,7 @@ def test_convert_same_unit():
|
|||
assert distance_util.convert(7, LENGTH_INCHES, LENGTH_INCHES) == 7
|
||||
|
||||
|
||||
def test_convert_invalid_unit():
|
||||
def test_convert_invalid_unit() -> None:
|
||||
"""Test exception is thrown for invalid units."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
distance_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
|
||||
|
@ -46,7 +46,7 @@ def test_convert_invalid_unit():
|
|||
distance_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)
|
||||
|
||||
|
||||
def test_convert_nonnumeric_value():
|
||||
def test_convert_nonnumeric_value() -> None:
|
||||
"""Test exception is thrown for nonnumeric type."""
|
||||
with pytest.raises(TypeError):
|
||||
distance_util.convert("a", LENGTH_KILOMETERS, LENGTH_METERS)
|
||||
|
|
|
@ -20,17 +20,17 @@ def teardown():
|
|||
dt_util.set_default_time_zone(DEFAULT_TIME_ZONE)
|
||||
|
||||
|
||||
def test_get_time_zone_retrieves_valid_time_zone():
|
||||
def test_get_time_zone_retrieves_valid_time_zone() -> None:
|
||||
"""Test getting a time zone."""
|
||||
assert dt_util.get_time_zone(TEST_TIME_ZONE) is not None
|
||||
|
||||
|
||||
def test_get_time_zone_returns_none_for_garbage_time_zone():
|
||||
def test_get_time_zone_returns_none_for_garbage_time_zone() -> None:
|
||||
"""Test getting a non existing time zone."""
|
||||
assert dt_util.get_time_zone("Non existing time zone") is None
|
||||
|
||||
|
||||
def test_set_default_time_zone():
|
||||
def test_set_default_time_zone() -> None:
|
||||
"""Test setting default time zone."""
|
||||
time_zone = dt_util.get_time_zone(TEST_TIME_ZONE)
|
||||
|
||||
|
@ -39,14 +39,14 @@ def test_set_default_time_zone():
|
|||
assert dt_util.now().tzinfo is time_zone
|
||||
|
||||
|
||||
def test_utcnow():
|
||||
def test_utcnow() -> None:
|
||||
"""Test the UTC now method."""
|
||||
assert abs(dt_util.utcnow().replace(tzinfo=None) - datetime.utcnow()) < timedelta(
|
||||
seconds=1
|
||||
)
|
||||
|
||||
|
||||
def test_now():
|
||||
def test_now() -> None:
|
||||
"""Test the now method."""
|
||||
dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE))
|
||||
|
||||
|
@ -55,21 +55,21 @@ def test_now():
|
|||
) < timedelta(seconds=1)
|
||||
|
||||
|
||||
def test_as_utc_with_naive_object():
|
||||
def test_as_utc_with_naive_object() -> None:
|
||||
"""Test the now method."""
|
||||
utcnow = datetime.utcnow()
|
||||
|
||||
assert utcnow == dt_util.as_utc(utcnow).replace(tzinfo=None)
|
||||
|
||||
|
||||
def test_as_utc_with_utc_object():
|
||||
def test_as_utc_with_utc_object() -> None:
|
||||
"""Test UTC time with UTC object."""
|
||||
utcnow = dt_util.utcnow()
|
||||
|
||||
assert utcnow == dt_util.as_utc(utcnow)
|
||||
|
||||
|
||||
def test_as_utc_with_local_object():
|
||||
def test_as_utc_with_local_object() -> None:
|
||||
"""Test the UTC time with local object."""
|
||||
dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE))
|
||||
localnow = dt_util.now()
|
||||
|
@ -79,19 +79,19 @@ def test_as_utc_with_local_object():
|
|||
assert localnow.tzinfo != utcnow.tzinfo
|
||||
|
||||
|
||||
def test_as_local_with_naive_object():
|
||||
def test_as_local_with_naive_object() -> None:
|
||||
"""Test local time with native object."""
|
||||
now = dt_util.now()
|
||||
assert abs(now - dt_util.as_local(datetime.utcnow())) < timedelta(seconds=1)
|
||||
|
||||
|
||||
def test_as_local_with_local_object():
|
||||
def test_as_local_with_local_object() -> None:
|
||||
"""Test local with local object."""
|
||||
now = dt_util.now()
|
||||
assert now == now
|
||||
|
||||
|
||||
def test_as_local_with_utc_object():
|
||||
def test_as_local_with_utc_object() -> None:
|
||||
"""Test local time with UTC object."""
|
||||
dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE))
|
||||
|
||||
|
@ -102,20 +102,20 @@ def test_as_local_with_utc_object():
|
|||
assert localnow.tzinfo != utcnow.tzinfo
|
||||
|
||||
|
||||
def test_utc_from_timestamp():
|
||||
def test_utc_from_timestamp() -> None:
|
||||
"""Test utc_from_timestamp method."""
|
||||
assert datetime(1986, 7, 9, tzinfo=dt_util.UTC) == dt_util.utc_from_timestamp(
|
||||
521251200
|
||||
)
|
||||
|
||||
|
||||
def test_timestamp_to_utc():
|
||||
def test_timestamp_to_utc() -> None:
|
||||
"""Test we can convert a utc datetime to a timestamp."""
|
||||
utc_now = dt_util.utcnow()
|
||||
assert dt_util.utc_to_timestamp(utc_now) == utc_now.timestamp()
|
||||
|
||||
|
||||
def test_as_timestamp():
|
||||
def test_as_timestamp() -> None:
|
||||
"""Test as_timestamp method."""
|
||||
ts = 1462401234
|
||||
utc_dt = dt_util.utc_from_timestamp(ts)
|
||||
|
@ -129,7 +129,7 @@ def test_as_timestamp():
|
|||
assert delta == 1
|
||||
|
||||
|
||||
def test_parse_datetime_converts_correctly():
|
||||
def test_parse_datetime_converts_correctly() -> None:
|
||||
"""Test parse_datetime converts strings."""
|
||||
assert datetime(1986, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC) == dt_util.parse_datetime(
|
||||
"1986-07-09T12:00:00Z"
|
||||
|
@ -140,7 +140,7 @@ def test_parse_datetime_converts_correctly():
|
|||
assert utcnow == dt_util.parse_datetime(utcnow.isoformat())
|
||||
|
||||
|
||||
def test_parse_datetime_returns_none_for_incorrect_format():
|
||||
def test_parse_datetime_returns_none_for_incorrect_format() -> None:
|
||||
"""Test parse_datetime returns None if incorrect format."""
|
||||
assert dt_util.parse_datetime("not a datetime string") is None
|
||||
|
||||
|
@ -171,7 +171,7 @@ def test_parse_duration(
|
|||
assert dt_util.parse_duration(duration_string) == expected_result
|
||||
|
||||
|
||||
def test_get_age():
|
||||
def test_get_age() -> None:
|
||||
"""Test get_age."""
|
||||
diff = dt_util.now() - timedelta(seconds=0)
|
||||
assert dt_util.get_age(diff) == "0 seconds"
|
||||
|
@ -207,7 +207,7 @@ def test_get_age():
|
|||
assert dt_util.get_age(diff) == "1 year"
|
||||
|
||||
|
||||
def test_parse_time_expression():
|
||||
def test_parse_time_expression() -> None:
|
||||
"""Test parse_time_expression."""
|
||||
assert list(range(60)) == dt_util.parse_time_expression("*", 0, 59)
|
||||
assert list(range(60)) == dt_util.parse_time_expression(None, 0, 59)
|
||||
|
@ -225,7 +225,7 @@ def test_parse_time_expression():
|
|||
dt_util.parse_time_expression(61, 0, 60)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_basic():
|
||||
def test_find_next_time_expression_time_basic() -> None:
|
||||
"""Test basic stuff for find_next_time_expression_time."""
|
||||
|
||||
def find(dt, hour, minute, second):
|
||||
|
@ -257,7 +257,7 @@ def test_find_next_time_expression_time_basic():
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_dst():
|
||||
def test_find_next_time_expression_time_dst() -> None:
|
||||
"""Test daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("Europe/Vienna")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -427,7 +427,7 @@ def test_find_next_time_expression_exiting_dst(now_dt, expected_dt):
|
|||
assert dt_util.as_utc(res_dt) == dt_util.as_utc(expected_dt)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_dst_chicago():
|
||||
def test_find_next_time_expression_time_dst_chicago() -> None:
|
||||
"""Test daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -503,7 +503,7 @@ def _get_matches(hours, minutes, seconds):
|
|||
return matching_hours, matching_minutes, matching_seconds
|
||||
|
||||
|
||||
def test_find_next_time_expression_day_before_dst_change_the_same_time():
|
||||
def test_find_next_time_expression_day_before_dst_change_the_same_time() -> None:
|
||||
"""Test the day before DST to establish behavior without DST."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -524,7 +524,9 @@ def test_find_next_time_expression_day_before_dst_change_the_same_time():
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_30_s():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_30_s() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time 30s into the future."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -547,7 +549,9 @@ def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_30_s()
|
|||
assert next_time.fold == 0
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_same_time():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_same_time() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time with the same time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -570,7 +574,9 @@ def test_find_next_time_expression_time_leave_dst_chicago_before_the_fold_same_t
|
|||
assert next_time.fold == 0
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_same_time():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_same_time() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -594,7 +600,9 @@ def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_same_tim
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_ahead_1_hour_10_min():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_ahead_1_hour_10_min() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -620,7 +628,9 @@ def test_find_next_time_expression_time_leave_dst_chicago_into_the_fold_ahead_1_
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_inside_the_fold_ahead_10_min():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_inside_the_fold_ahead_10_min() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -646,7 +656,9 @@ def test_find_next_time_expression_time_leave_dst_chicago_inside_the_fold_ahead_
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_past_the_fold_ahead_2_hour_10_min():
|
||||
def test_find_next_time_expression_time_leave_dst_chicago_past_the_fold_ahead_2_hour_10_min() -> (
|
||||
None
|
||||
):
|
||||
"""Test leaving daylight saving time for find_next_time_expression_time."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -672,7 +684,7 @@ def test_find_next_time_expression_time_leave_dst_chicago_past_the_fold_ahead_2_
|
|||
)
|
||||
|
||||
|
||||
def test_find_next_time_expression_microseconds():
|
||||
def test_find_next_time_expression_microseconds() -> None:
|
||||
"""Test finding next time expression with microsecond clock drift."""
|
||||
hour_minute_second = (None, "5", "10")
|
||||
test_time = datetime(2022, 5, 13, 0, 5, 9, tzinfo=dt_util.UTC)
|
||||
|
@ -695,7 +707,9 @@ def test_find_next_time_expression_microseconds():
|
|||
assert time_after == datetime(2022, 5, 13, 1, 5, 10, tzinfo=dt_util.UTC)
|
||||
|
||||
|
||||
def test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_dst():
|
||||
def test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_dst() -> (
|
||||
None
|
||||
):
|
||||
"""Test finding next time expression tenth second pattern does not drift entering dst."""
|
||||
tz = dt_util.get_time_zone("America/Chicago")
|
||||
dt_util.set_default_time_zone(tz)
|
||||
|
@ -722,6 +736,6 @@ def test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_
|
|||
prev_target = next_target
|
||||
|
||||
|
||||
def test_monotonic_time_coarse():
|
||||
def test_monotonic_time_coarse() -> None:
|
||||
"""Test monotonic time coarse."""
|
||||
assert abs(time.monotonic() - dt_util.monotonic_time_coarse()) < 1
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant import util
|
|||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
||||
def test_raise_if_invalid_filename():
|
||||
def test_raise_if_invalid_filename() -> None:
|
||||
"""Test raise_if_invalid_filename."""
|
||||
assert util.raise_if_invalid_filename("test") is None
|
||||
|
||||
|
@ -25,7 +25,7 @@ def test_raise_if_invalid_filename():
|
|||
util.raise_if_invalid_filename("\\../test")
|
||||
|
||||
|
||||
def test_raise_if_invalid_path():
|
||||
def test_raise_if_invalid_path() -> None:
|
||||
"""Test raise_if_invalid_path."""
|
||||
assert util.raise_if_invalid_path("test/path") is None
|
||||
|
||||
|
@ -36,7 +36,7 @@ def test_raise_if_invalid_path():
|
|||
assert util.raise_if_invalid_path("~/../test/path")
|
||||
|
||||
|
||||
def test_slugify():
|
||||
def test_slugify() -> None:
|
||||
"""Test slugify."""
|
||||
assert util.slugify("T-!@#$!#@$!$est") == "t_est"
|
||||
assert util.slugify("Test More") == "test_more"
|
||||
|
@ -61,7 +61,7 @@ def test_slugify():
|
|||
assert util.slugify(None) == ""
|
||||
|
||||
|
||||
def test_repr_helper():
|
||||
def test_repr_helper() -> None:
|
||||
"""Test repr_helper."""
|
||||
assert util.repr_helper("A") == "A"
|
||||
assert util.repr_helper(5) == "5"
|
||||
|
@ -76,7 +76,7 @@ def test_repr_helper():
|
|||
)
|
||||
|
||||
|
||||
def test_convert():
|
||||
def test_convert() -> None:
|
||||
"""Test convert."""
|
||||
assert util.convert("5", int) == 5
|
||||
assert util.convert("5", float) == 5.0
|
||||
|
@ -86,13 +86,13 @@ def test_convert():
|
|||
assert util.convert(object, int, 1) == 1
|
||||
|
||||
|
||||
def test_ensure_unique_string():
|
||||
def test_ensure_unique_string() -> None:
|
||||
"""Test ensure_unique_string."""
|
||||
assert util.ensure_unique_string("Beer", ["Beer", "Beer_2"]) == "Beer_3"
|
||||
assert util.ensure_unique_string("Beer", ["Wine", "Soda"]) == "Beer"
|
||||
|
||||
|
||||
def test_throttle():
|
||||
def test_throttle() -> None:
|
||||
"""Test the add cooldown decorator."""
|
||||
calls1 = []
|
||||
calls2 = []
|
||||
|
@ -145,7 +145,7 @@ def test_throttle():
|
|||
assert len(calls2) == 2
|
||||
|
||||
|
||||
def test_throttle_per_instance():
|
||||
def test_throttle_per_instance() -> None:
|
||||
"""Test that the throttle method is done per instance of a class."""
|
||||
|
||||
class Tester:
|
||||
|
@ -160,7 +160,7 @@ def test_throttle_per_instance():
|
|||
assert Tester().hello()
|
||||
|
||||
|
||||
def test_throttle_on_method():
|
||||
def test_throttle_on_method() -> None:
|
||||
"""Test that throttle works when wrapping a method."""
|
||||
|
||||
class Tester:
|
||||
|
@ -177,7 +177,7 @@ def test_throttle_on_method():
|
|||
assert throttled() is None
|
||||
|
||||
|
||||
def test_throttle_on_two_method():
|
||||
def test_throttle_on_two_method() -> None:
|
||||
"""Test that throttle works when wrapping two methods."""
|
||||
|
||||
class Tester:
|
||||
|
|
|
@ -44,7 +44,7 @@ def _path_for(leaf_name):
|
|||
return os.path.join(TMP_DIR, f"{leaf_name}.json")
|
||||
|
||||
|
||||
def test_save_and_load():
|
||||
def test_save_and_load() -> None:
|
||||
"""Test saving and loading back."""
|
||||
fname = _path_for("test1")
|
||||
save_json(fname, TEST_JSON_A)
|
||||
|
@ -52,7 +52,7 @@ def test_save_and_load():
|
|||
assert data == TEST_JSON_A
|
||||
|
||||
|
||||
def test_save_and_load_int_keys():
|
||||
def test_save_and_load_int_keys() -> None:
|
||||
"""Test saving and loading back stringifies the keys."""
|
||||
fname = _path_for("test1")
|
||||
save_json(fname, {1: "a", 2: "b"})
|
||||
|
@ -60,7 +60,7 @@ def test_save_and_load_int_keys():
|
|||
assert data == {"1": "a", "2": "b"}
|
||||
|
||||
|
||||
def test_save_and_load_private():
|
||||
def test_save_and_load_private() -> None:
|
||||
"""Test we can load private files and that they are protected."""
|
||||
fname = _path_for("test2")
|
||||
save_json(fname, TEST_JSON_A, private=True)
|
||||
|
@ -80,7 +80,7 @@ def test_overwrite_and_reload(atomic_writes):
|
|||
assert data == TEST_JSON_B
|
||||
|
||||
|
||||
def test_save_bad_data():
|
||||
def test_save_bad_data() -> None:
|
||||
"""Test error from trying to save unserializable data."""
|
||||
|
||||
class CannotSerializeMe:
|
||||
|
@ -94,7 +94,7 @@ def test_save_bad_data():
|
|||
)
|
||||
|
||||
|
||||
def test_load_bad_data():
|
||||
def test_load_bad_data() -> None:
|
||||
"""Test error from trying to load unserialisable data."""
|
||||
fname = _path_for("test5")
|
||||
with open(fname, "w") as fh:
|
||||
|
@ -103,7 +103,7 @@ def test_load_bad_data():
|
|||
load_json(fname)
|
||||
|
||||
|
||||
def test_custom_encoder():
|
||||
def test_custom_encoder() -> None:
|
||||
"""Test serializing with a custom encoder."""
|
||||
|
||||
class MockJSONEncoder(JSONEncoder):
|
||||
|
@ -119,7 +119,7 @@ def test_custom_encoder():
|
|||
assert data == "9"
|
||||
|
||||
|
||||
def test_default_encoder_is_passed():
|
||||
def test_default_encoder_is_passed() -> None:
|
||||
"""Test we use orjson if they pass in the default encoder."""
|
||||
fname = _path_for("test6")
|
||||
with patch(
|
||||
|
@ -134,7 +134,7 @@ def test_default_encoder_is_passed():
|
|||
assert data == {"any": [1]}
|
||||
|
||||
|
||||
def test_find_unserializable_data():
|
||||
def test_find_unserializable_data() -> None:
|
||||
"""Find unserializeable data."""
|
||||
assert find_paths_unserializable_data(1) == {}
|
||||
assert find_paths_unserializable_data([1, 2]) == {}
|
||||
|
|
|
@ -37,7 +37,7 @@ async def raising_session(event_loop):
|
|||
return Mock(get=Mock(side_effect=aiohttp.ClientError))
|
||||
|
||||
|
||||
def test_get_distance_to_same_place():
|
||||
def test_get_distance_to_same_place() -> None:
|
||||
"""Test getting the distance."""
|
||||
meters = location_util.distance(
|
||||
COORDINATES_PARIS[0],
|
||||
|
@ -49,7 +49,7 @@ def test_get_distance_to_same_place():
|
|||
assert meters == 0
|
||||
|
||||
|
||||
def test_get_distance():
|
||||
def test_get_distance() -> None:
|
||||
"""Test getting the distance."""
|
||||
meters = location_util.distance(
|
||||
COORDINATES_PARIS[0],
|
||||
|
@ -61,13 +61,13 @@ def test_get_distance():
|
|||
assert meters / 1000 - DISTANCE_KM < 0.01
|
||||
|
||||
|
||||
def test_get_kilometers():
|
||||
def test_get_kilometers() -> None:
|
||||
"""Test getting the distance between given coordinates in km."""
|
||||
kilometers = location_util.vincenty(COORDINATES_PARIS, COORDINATES_NEW_YORK)
|
||||
assert round(kilometers, 2) == DISTANCE_KM
|
||||
|
||||
|
||||
def test_get_miles():
|
||||
def test_get_miles() -> None:
|
||||
"""Test getting the distance between given coordinates in miles."""
|
||||
miles = location_util.vincenty(COORDINATES_PARIS, COORDINATES_NEW_YORK, miles=True)
|
||||
assert round(miles, 2) == DISTANCE_MILES
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.core import callback, is_callback
|
|||
import homeassistant.util.logging as logging_util
|
||||
|
||||
|
||||
def test_sensitive_data_filter():
|
||||
def test_sensitive_data_filter() -> None:
|
||||
"""Test the logging sensitive data filter."""
|
||||
log_filter = logging_util.HideSensitiveDataFilter("mock_sensitive")
|
||||
|
||||
|
@ -90,7 +90,7 @@ async def test_async_create_catching_coro(hass, caplog):
|
|||
assert "in test_async_create_catching_coro" in caplog.text
|
||||
|
||||
|
||||
def test_catch_log_exception():
|
||||
def test_catch_log_exception() -> None:
|
||||
"""Test it is still a callback after wrapping including partial."""
|
||||
|
||||
async def async_meth():
|
||||
|
|
|
@ -5,7 +5,7 @@ from ipaddress import ip_address
|
|||
import homeassistant.util.network as network_util
|
||||
|
||||
|
||||
def test_is_loopback():
|
||||
def test_is_loopback() -> None:
|
||||
"""Test loopback addresses."""
|
||||
assert network_util.is_loopback(ip_address("127.0.0.2"))
|
||||
assert network_util.is_loopback(ip_address("127.0.0.1"))
|
||||
|
@ -17,7 +17,7 @@ def test_is_loopback():
|
|||
assert not network_util.is_loopback(ip_address("2600:1404:400:1a4::356e"))
|
||||
|
||||
|
||||
def test_is_private():
|
||||
def test_is_private() -> None:
|
||||
"""Test private addresses."""
|
||||
assert network_util.is_private(ip_address("192.168.0.1"))
|
||||
assert network_util.is_private(ip_address("172.16.12.0"))
|
||||
|
@ -27,7 +27,7 @@ def test_is_private():
|
|||
assert not network_util.is_private(ip_address("::1"))
|
||||
|
||||
|
||||
def test_is_link_local():
|
||||
def test_is_link_local() -> None:
|
||||
"""Test link local addresses."""
|
||||
assert network_util.is_link_local(ip_address("169.254.12.3"))
|
||||
assert network_util.is_link_local(ip_address("fe80::1234:5678:abcd"))
|
||||
|
@ -35,13 +35,13 @@ def test_is_link_local():
|
|||
assert not network_util.is_link_local(ip_address("::1"))
|
||||
|
||||
|
||||
def test_is_invalid():
|
||||
def test_is_invalid() -> None:
|
||||
"""Test invalid address."""
|
||||
assert network_util.is_invalid(ip_address("0.0.0.0"))
|
||||
assert not network_util.is_invalid(ip_address("127.0.0.1"))
|
||||
|
||||
|
||||
def test_is_local():
|
||||
def test_is_local() -> None:
|
||||
"""Test local addresses."""
|
||||
assert network_util.is_local(ip_address("192.168.0.1"))
|
||||
assert network_util.is_local(ip_address("127.0.0.1"))
|
||||
|
@ -54,7 +54,7 @@ def test_is_local():
|
|||
assert not network_util.is_local(ip_address("::ffff:208.5.4.2"))
|
||||
|
||||
|
||||
def test_is_ip_address():
|
||||
def test_is_ip_address() -> None:
|
||||
"""Test if strings are IP addresses."""
|
||||
assert network_util.is_ip_address("192.168.0.1")
|
||||
assert network_util.is_ip_address("8.8.8.8")
|
||||
|
@ -64,7 +64,7 @@ def test_is_ip_address():
|
|||
assert not network_util.is_ip_address("example.com")
|
||||
|
||||
|
||||
def test_is_ipv4_address():
|
||||
def test_is_ipv4_address() -> None:
|
||||
"""Test if strings are IPv4 addresses."""
|
||||
assert network_util.is_ipv4_address("192.168.0.1") is True
|
||||
assert network_util.is_ipv4_address("8.8.8.8") is True
|
||||
|
@ -73,14 +73,14 @@ def test_is_ipv4_address():
|
|||
assert network_util.is_ipv4_address("example.com") is False
|
||||
|
||||
|
||||
def test_is_ipv6_address():
|
||||
def test_is_ipv6_address() -> None:
|
||||
"""Test if strings are IPv6 addresses."""
|
||||
assert network_util.is_ipv6_address("::1") is True
|
||||
assert network_util.is_ipv6_address("8.8.8.8") is False
|
||||
assert network_util.is_ipv6_address("8.8.8.8") is False
|
||||
|
||||
|
||||
def test_is_valid_host():
|
||||
def test_is_valid_host() -> None:
|
||||
"""Test if strings are IPv6 addresses."""
|
||||
assert network_util.is_host_valid("::1")
|
||||
assert network_util.is_host_valid("::ffff:127.0.0.0")
|
||||
|
@ -104,7 +104,7 @@ def test_is_valid_host():
|
|||
assert not network_util.is_host_valid("verydeepdomain." * 18)
|
||||
|
||||
|
||||
def test_normalize_url():
|
||||
def test_normalize_url() -> None:
|
||||
"""Test the normalizing of URLs."""
|
||||
assert network_util.normalize_url("http://example.com") == "http://example.com"
|
||||
assert network_util.normalize_url("https://example.com") == "https://example.com"
|
||||
|
|
|
@ -237,7 +237,7 @@ async def test_async_get_user_site(mock_env_copy):
|
|||
assert ret == os.path.join(deps_dir, "lib_dir")
|
||||
|
||||
|
||||
def test_check_package_global():
|
||||
def test_check_package_global() -> None:
|
||||
"""Test for an installed package."""
|
||||
first_package = list(pkg_resources.working_set)[0]
|
||||
installed_package = first_package.project_name
|
||||
|
@ -250,12 +250,12 @@ def test_check_package_global():
|
|||
assert not package.is_installed(f"{installed_package}<{installed_version}")
|
||||
|
||||
|
||||
def test_check_package_zip():
|
||||
def test_check_package_zip() -> None:
|
||||
"""Test for an installed zip package."""
|
||||
assert not package.is_installed(TEST_ZIP_REQ)
|
||||
|
||||
|
||||
def test_get_distribution_falls_back_to_version():
|
||||
def test_get_distribution_falls_back_to_version() -> None:
|
||||
"""Test for get_distribution failing and fallback to version."""
|
||||
first_package = list(pkg_resources.working_set)[0]
|
||||
installed_package = first_package.project_name
|
||||
|
@ -272,7 +272,7 @@ def test_get_distribution_falls_back_to_version():
|
|||
assert not package.is_installed(f"{installed_package}<{installed_version}")
|
||||
|
||||
|
||||
def test_check_package_previous_failed_install():
|
||||
def test_check_package_previous_failed_install() -> None:
|
||||
"""Test for when a previously install package failed and left cruft behind."""
|
||||
first_package = list(pkg_resources.working_set)[0]
|
||||
installed_package = first_package.project_name
|
||||
|
|
|
@ -15,7 +15,7 @@ def test_raise_deprecation_warning(caplog: pytest.LogCaptureFixture) -> None:
|
|||
assert "use unit_conversion.PressureConverter instead" in caplog.text
|
||||
|
||||
|
||||
def test_convert_same_unit():
|
||||
def test_convert_same_unit() -> None:
|
||||
"""Test conversion from any unit to same unit."""
|
||||
assert pressure_util.convert(2, UnitOfPressure.PA, UnitOfPressure.PA) == 2
|
||||
assert pressure_util.convert(3, UnitOfPressure.HPA, UnitOfPressure.HPA) == 3
|
||||
|
@ -26,7 +26,7 @@ def test_convert_same_unit():
|
|||
assert pressure_util.convert(8, UnitOfPressure.MMHG, UnitOfPressure.MMHG) == 8
|
||||
|
||||
|
||||
def test_convert_invalid_unit():
|
||||
def test_convert_invalid_unit() -> None:
|
||||
"""Test exception is thrown for invalid units."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
pressure_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
|
||||
|
@ -35,13 +35,13 @@ def test_convert_invalid_unit():
|
|||
pressure_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)
|
||||
|
||||
|
||||
def test_convert_nonnumeric_value():
|
||||
def test_convert_nonnumeric_value() -> None:
|
||||
"""Test exception is thrown for nonnumeric type."""
|
||||
with pytest.raises(TypeError):
|
||||
pressure_util.convert("a", UnitOfPressure.HPA, UnitOfPressure.INHG)
|
||||
|
||||
|
||||
def test_convert_from_hpascals():
|
||||
def test_convert_from_hpascals() -> None:
|
||||
"""Test conversion from hPA to other units."""
|
||||
hpascals = 1000
|
||||
assert pressure_util.convert(
|
||||
|
@ -64,7 +64,7 @@ def test_convert_from_hpascals():
|
|||
) == pytest.approx(100)
|
||||
|
||||
|
||||
def test_convert_from_kpascals():
|
||||
def test_convert_from_kpascals() -> None:
|
||||
"""Test conversion from hPA to other units."""
|
||||
kpascals = 100
|
||||
assert pressure_util.convert(
|
||||
|
@ -87,7 +87,7 @@ def test_convert_from_kpascals():
|
|||
) == pytest.approx(100)
|
||||
|
||||
|
||||
def test_convert_from_inhg():
|
||||
def test_convert_from_inhg() -> None:
|
||||
"""Test conversion from inHg to other units."""
|
||||
inhg = 30
|
||||
assert pressure_util.convert(
|
||||
|
@ -113,7 +113,7 @@ def test_convert_from_inhg():
|
|||
) == pytest.approx(762)
|
||||
|
||||
|
||||
def test_convert_from_mmhg():
|
||||
def test_convert_from_mmhg() -> None:
|
||||
"""Test conversion from mmHg to other units."""
|
||||
inhg = 30
|
||||
assert pressure_util.convert(
|
||||
|
|
|
@ -6,7 +6,7 @@ import pytest
|
|||
from homeassistant.util.read_only_dict import ReadOnlyDict
|
||||
|
||||
|
||||
def test_read_only_dict():
|
||||
def test_read_only_dict() -> None:
|
||||
"""Test read only dictionary."""
|
||||
data = ReadOnlyDict({"hello": "world"})
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ def test_raise_deprecation_warning(caplog: pytest.LogCaptureFixture) -> None:
|
|||
assert "use unit_conversion.SpeedConverter instead" in caplog.text
|
||||
|
||||
|
||||
def test_convert_same_unit():
|
||||
def test_convert_same_unit() -> None:
|
||||
"""Test conversion from any unit to same unit."""
|
||||
assert speed_util.convert(2, SPEED_INCHES_PER_DAY, SPEED_INCHES_PER_DAY) == 2
|
||||
assert speed_util.convert(3, SPEED_INCHES_PER_HOUR, SPEED_INCHES_PER_HOUR) == 3
|
||||
|
@ -45,7 +45,7 @@ def test_convert_same_unit():
|
|||
)
|
||||
|
||||
|
||||
def test_convert_invalid_unit():
|
||||
def test_convert_invalid_unit() -> None:
|
||||
"""Test exception is thrown for invalid units."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
speed_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
|
||||
|
@ -54,7 +54,7 @@ def test_convert_invalid_unit():
|
|||
speed_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)
|
||||
|
||||
|
||||
def test_convert_nonnumeric_value():
|
||||
def test_convert_nonnumeric_value() -> None:
|
||||
"""Test exception is thrown for nonnumeric type."""
|
||||
with pytest.raises(TypeError):
|
||||
speed_util.convert(
|
||||
|
|
|
@ -32,14 +32,14 @@ def test_deprecated_functions(
|
|||
assert convert(value) == expected
|
||||
|
||||
|
||||
def test_convert_same_unit():
|
||||
def test_convert_same_unit() -> None:
|
||||
"""Test conversion from any unit to same unit."""
|
||||
assert temperature_util.convert(2, TEMP_CELSIUS, TEMP_CELSIUS) == 2
|
||||
assert temperature_util.convert(3, TEMP_FAHRENHEIT, TEMP_FAHRENHEIT) == 3
|
||||
assert temperature_util.convert(4, TEMP_KELVIN, TEMP_KELVIN) == 4
|
||||
|
||||
|
||||
def test_convert_invalid_unit():
|
||||
def test_convert_invalid_unit() -> None:
|
||||
"""Test exception is thrown for invalid units."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
temperature_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
|
||||
|
@ -48,13 +48,13 @@ def test_convert_invalid_unit():
|
|||
temperature_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)
|
||||
|
||||
|
||||
def test_convert_nonnumeric_value():
|
||||
def test_convert_nonnumeric_value() -> None:
|
||||
"""Test exception is thrown for nonnumeric type."""
|
||||
with pytest.raises(TypeError):
|
||||
temperature_util.convert("a", TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
|
||||
|
||||
def test_convert_from_celsius():
|
||||
def test_convert_from_celsius() -> None:
|
||||
"""Test conversion from C to other units."""
|
||||
celsius = 100
|
||||
assert temperature_util.convert(
|
||||
|
@ -72,7 +72,7 @@ def test_convert_from_celsius():
|
|||
) == pytest.approx(100)
|
||||
|
||||
|
||||
def test_convert_from_fahrenheit():
|
||||
def test_convert_from_fahrenheit() -> None:
|
||||
"""Test conversion from F to other units."""
|
||||
fahrenheit = 100
|
||||
assert temperature_util.convert(
|
||||
|
@ -90,7 +90,7 @@ def test_convert_from_fahrenheit():
|
|||
) == pytest.approx(55.55555555555556)
|
||||
|
||||
|
||||
def test_convert_from_kelvin():
|
||||
def test_convert_from_kelvin() -> None:
|
||||
"""Test conversion from K to other units."""
|
||||
kelvin = 100
|
||||
assert temperature_util.convert(kelvin, TEMP_KELVIN, TEMP_CELSIUS) == pytest.approx(
|
||||
|
|
|
@ -35,7 +35,7 @@ SYSTEM_NAME = "TEST"
|
|||
INVALID_UNIT = "INVALID"
|
||||
|
||||
|
||||
def test_invalid_units():
|
||||
def test_invalid_units() -> None:
|
||||
"""Test errors are raised when invalid units are passed in."""
|
||||
with pytest.raises(ValueError):
|
||||
UnitSystem(
|
||||
|
@ -129,7 +129,7 @@ def test_invalid_units():
|
|||
)
|
||||
|
||||
|
||||
def test_invalid_value():
|
||||
def test_invalid_value() -> None:
|
||||
"""Test no conversion happens if value is non-numeric."""
|
||||
with pytest.raises(TypeError):
|
||||
METRIC_SYSTEM.length("25a", UnitOfLength.KILOMETERS)
|
||||
|
@ -145,7 +145,7 @@ def test_invalid_value():
|
|||
METRIC_SYSTEM.accumulated_precipitation("50mm", UnitOfLength.MILLIMETERS)
|
||||
|
||||
|
||||
def test_as_dict():
|
||||
def test_as_dict() -> None:
|
||||
"""Test that the as_dict() method returns the expected dictionary."""
|
||||
expected = {
|
||||
LENGTH: UnitOfLength.KILOMETERS,
|
||||
|
@ -160,18 +160,18 @@ def test_as_dict():
|
|||
assert expected == METRIC_SYSTEM.as_dict()
|
||||
|
||||
|
||||
def test_temperature_same_unit():
|
||||
def test_temperature_same_unit() -> None:
|
||||
"""Test no conversion happens if to unit is same as from unit."""
|
||||
assert METRIC_SYSTEM.temperature(5, METRIC_SYSTEM.temperature_unit) == 5
|
||||
|
||||
|
||||
def test_temperature_unknown_unit():
|
||||
def test_temperature_unknown_unit() -> None:
|
||||
"""Test no conversion happens if unknown unit."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
METRIC_SYSTEM.temperature(5, "abc")
|
||||
|
||||
|
||||
def test_temperature_to_metric():
|
||||
def test_temperature_to_metric() -> None:
|
||||
"""Test temperature conversion to metric system."""
|
||||
assert METRIC_SYSTEM.temperature(25, METRIC_SYSTEM.temperature_unit) == 25
|
||||
assert (
|
||||
|
@ -180,19 +180,19 @@ def test_temperature_to_metric():
|
|||
)
|
||||
|
||||
|
||||
def test_temperature_to_imperial():
|
||||
def test_temperature_to_imperial() -> None:
|
||||
"""Test temperature conversion to imperial system."""
|
||||
assert IMPERIAL_SYSTEM.temperature(77, IMPERIAL_SYSTEM.temperature_unit) == 77
|
||||
assert IMPERIAL_SYSTEM.temperature(25, METRIC_SYSTEM.temperature_unit) == 77
|
||||
|
||||
|
||||
def test_length_unknown_unit():
|
||||
def test_length_unknown_unit() -> None:
|
||||
"""Test length conversion with unknown from unit."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
METRIC_SYSTEM.length(5, "fr")
|
||||
|
||||
|
||||
def test_length_to_metric():
|
||||
def test_length_to_metric() -> None:
|
||||
"""Test length conversion to metric system."""
|
||||
assert METRIC_SYSTEM.length(100, METRIC_SYSTEM.length_unit) == 100
|
||||
assert METRIC_SYSTEM.length(5, IMPERIAL_SYSTEM.length_unit) == pytest.approx(
|
||||
|
@ -200,7 +200,7 @@ def test_length_to_metric():
|
|||
)
|
||||
|
||||
|
||||
def test_length_to_imperial():
|
||||
def test_length_to_imperial() -> None:
|
||||
"""Test length conversion to imperial system."""
|
||||
assert IMPERIAL_SYSTEM.length(100, IMPERIAL_SYSTEM.length_unit) == 100
|
||||
assert IMPERIAL_SYSTEM.length(5, METRIC_SYSTEM.length_unit) == pytest.approx(
|
||||
|
@ -208,13 +208,13 @@ def test_length_to_imperial():
|
|||
)
|
||||
|
||||
|
||||
def test_wind_speed_unknown_unit():
|
||||
def test_wind_speed_unknown_unit() -> None:
|
||||
"""Test wind_speed conversion with unknown from unit."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
METRIC_SYSTEM.length(5, "turtles")
|
||||
|
||||
|
||||
def test_wind_speed_to_metric():
|
||||
def test_wind_speed_to_metric() -> None:
|
||||
"""Test length conversion to metric system."""
|
||||
assert METRIC_SYSTEM.wind_speed(100, METRIC_SYSTEM.wind_speed_unit) == 100
|
||||
# 1 m/s is about 2.237 mph
|
||||
|
@ -223,7 +223,7 @@ def test_wind_speed_to_metric():
|
|||
) == pytest.approx(1000, abs=0.1)
|
||||
|
||||
|
||||
def test_wind_speed_to_imperial():
|
||||
def test_wind_speed_to_imperial() -> None:
|
||||
"""Test wind_speed conversion to imperial system."""
|
||||
assert IMPERIAL_SYSTEM.wind_speed(100, IMPERIAL_SYSTEM.wind_speed_unit) == 100
|
||||
assert IMPERIAL_SYSTEM.wind_speed(
|
||||
|
@ -231,18 +231,18 @@ def test_wind_speed_to_imperial():
|
|||
) == pytest.approx(2237, abs=0.1)
|
||||
|
||||
|
||||
def test_pressure_same_unit():
|
||||
def test_pressure_same_unit() -> None:
|
||||
"""Test no conversion happens if to unit is same as from unit."""
|
||||
assert METRIC_SYSTEM.pressure(5, METRIC_SYSTEM.pressure_unit) == 5
|
||||
|
||||
|
||||
def test_pressure_unknown_unit():
|
||||
def test_pressure_unknown_unit() -> None:
|
||||
"""Test no conversion happens if unknown unit."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
METRIC_SYSTEM.pressure(5, "K")
|
||||
|
||||
|
||||
def test_pressure_to_metric():
|
||||
def test_pressure_to_metric() -> None:
|
||||
"""Test pressure conversion to metric system."""
|
||||
assert METRIC_SYSTEM.pressure(25, METRIC_SYSTEM.pressure_unit) == 25
|
||||
assert METRIC_SYSTEM.pressure(14.7, IMPERIAL_SYSTEM.pressure_unit) == pytest.approx(
|
||||
|
@ -250,7 +250,7 @@ def test_pressure_to_metric():
|
|||
)
|
||||
|
||||
|
||||
def test_pressure_to_imperial():
|
||||
def test_pressure_to_imperial() -> None:
|
||||
"""Test pressure conversion to imperial system."""
|
||||
assert IMPERIAL_SYSTEM.pressure(77, IMPERIAL_SYSTEM.pressure_unit) == 77
|
||||
assert IMPERIAL_SYSTEM.pressure(
|
||||
|
@ -258,7 +258,7 @@ def test_pressure_to_imperial():
|
|||
) == pytest.approx(14.7, abs=1e-4)
|
||||
|
||||
|
||||
def test_accumulated_precipitation_same_unit():
|
||||
def test_accumulated_precipitation_same_unit() -> None:
|
||||
"""Test no conversion happens if to unit is same as from unit."""
|
||||
assert (
|
||||
METRIC_SYSTEM.accumulated_precipitation(
|
||||
|
@ -268,13 +268,13 @@ def test_accumulated_precipitation_same_unit():
|
|||
)
|
||||
|
||||
|
||||
def test_accumulated_precipitation_unknown_unit():
|
||||
def test_accumulated_precipitation_unknown_unit() -> None:
|
||||
"""Test no conversion happens if unknown unit."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
METRIC_SYSTEM.accumulated_precipitation(5, "K")
|
||||
|
||||
|
||||
def test_accumulated_precipitation_to_metric():
|
||||
def test_accumulated_precipitation_to_metric() -> None:
|
||||
"""Test accumulated_precipitation conversion to metric system."""
|
||||
assert (
|
||||
METRIC_SYSTEM.accumulated_precipitation(
|
||||
|
@ -287,7 +287,7 @@ def test_accumulated_precipitation_to_metric():
|
|||
) == pytest.approx(254, abs=1e-4)
|
||||
|
||||
|
||||
def test_accumulated_precipitation_to_imperial():
|
||||
def test_accumulated_precipitation_to_imperial() -> None:
|
||||
"""Test accumulated_precipitation conversion to imperial system."""
|
||||
assert (
|
||||
IMPERIAL_SYSTEM.accumulated_precipitation(
|
||||
|
@ -300,7 +300,7 @@ def test_accumulated_precipitation_to_imperial():
|
|||
) == pytest.approx(10, abs=1e-4)
|
||||
|
||||
|
||||
def test_properties():
|
||||
def test_properties() -> None:
|
||||
"""Test the unit properties are returned as expected."""
|
||||
assert METRIC_SYSTEM.length_unit == UnitOfLength.KILOMETERS
|
||||
assert METRIC_SYSTEM.wind_speed_unit == UnitOfSpeed.METERS_PER_SECOND
|
||||
|
|
|
@ -40,7 +40,7 @@ def test_deprecated_functions(
|
|||
assert convert(value) == expected
|
||||
|
||||
|
||||
def test_convert_same_unit():
|
||||
def test_convert_same_unit() -> None:
|
||||
"""Test conversion from any unit to same unit."""
|
||||
assert volume_util.convert(2, VOLUME_LITERS, VOLUME_LITERS) == 2
|
||||
assert volume_util.convert(3, VOLUME_MILLILITERS, VOLUME_MILLILITERS) == 3
|
||||
|
@ -48,7 +48,7 @@ def test_convert_same_unit():
|
|||
assert volume_util.convert(5, VOLUME_FLUID_OUNCE, VOLUME_FLUID_OUNCE) == 5
|
||||
|
||||
|
||||
def test_convert_invalid_unit():
|
||||
def test_convert_invalid_unit() -> None:
|
||||
"""Test exception is thrown for invalid units."""
|
||||
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
|
||||
volume_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
|
||||
|
@ -57,13 +57,13 @@ def test_convert_invalid_unit():
|
|||
volume_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)
|
||||
|
||||
|
||||
def test_convert_nonnumeric_value():
|
||||
def test_convert_nonnumeric_value() -> None:
|
||||
"""Test exception is thrown for nonnumeric type."""
|
||||
with pytest.raises(TypeError):
|
||||
volume_util.convert("a", VOLUME_GALLONS, VOLUME_LITERS)
|
||||
|
||||
|
||||
def test_convert_from_liters():
|
||||
def test_convert_from_liters() -> None:
|
||||
"""Test conversion from liters to other units."""
|
||||
liters = 5
|
||||
assert volume_util.convert(liters, VOLUME_LITERS, VOLUME_GALLONS) == pytest.approx(
|
||||
|
@ -71,7 +71,7 @@ def test_convert_from_liters():
|
|||
)
|
||||
|
||||
|
||||
def test_convert_from_gallons():
|
||||
def test_convert_from_gallons() -> None:
|
||||
"""Test conversion from gallons to other units."""
|
||||
gallons = 5
|
||||
assert volume_util.convert(gallons, VOLUME_GALLONS, VOLUME_LITERS) == pytest.approx(
|
||||
|
@ -79,7 +79,7 @@ def test_convert_from_gallons():
|
|||
)
|
||||
|
||||
|
||||
def test_convert_from_cubic_meters():
|
||||
def test_convert_from_cubic_meters() -> None:
|
||||
"""Test conversion from cubic meter to other units."""
|
||||
cubic_meters = 5
|
||||
assert volume_util.convert(
|
||||
|
@ -87,7 +87,7 @@ def test_convert_from_cubic_meters():
|
|||
) == pytest.approx(176.5733335)
|
||||
|
||||
|
||||
def test_convert_from_cubic_feet():
|
||||
def test_convert_from_cubic_feet() -> None:
|
||||
"""Test conversion from cubic feet to cubic meters to other units."""
|
||||
cubic_feets = 500
|
||||
assert volume_util.convert(
|
||||
|
|
|
@ -67,7 +67,7 @@ def test_simple_dict(try_both_loaders):
|
|||
assert doc["key"] == "value"
|
||||
|
||||
|
||||
def test_unhashable_key():
|
||||
def test_unhashable_key() -> None:
|
||||
"""Test an unhashable key."""
|
||||
files = {YAML_CONFIG_FILE: "message:\n {{ states.state }}"}
|
||||
with pytest.raises(HomeAssistantError), patch_yaml_files(files):
|
||||
|
@ -477,7 +477,7 @@ def test_no_recursive_secrets(caplog, try_both_loaders):
|
|||
assert e.value.args == ("Secrets not supported in this YAML file",)
|
||||
|
||||
|
||||
def test_input_class():
|
||||
def test_input_class() -> None:
|
||||
"""Test input class."""
|
||||
input = yaml_loader.Input("hello")
|
||||
input2 = yaml_loader.Input("hello")
|
||||
|
@ -498,7 +498,7 @@ def test_input(try_both_loaders, try_both_dumpers):
|
|||
not os.environ.get("HASS_CI"),
|
||||
reason="This test validates that the CI has the C loader available",
|
||||
)
|
||||
def test_c_loader_is_available_in_ci():
|
||||
def test_c_loader_is_available_in_ci() -> None:
|
||||
"""Verify we are testing the C loader in the CI."""
|
||||
assert yaml.loader.HAS_C_LOADER is True
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.util.yaml import (
|
|||
)
|
||||
|
||||
|
||||
def test_extract_inputs():
|
||||
def test_extract_inputs() -> None:
|
||||
"""Test extracting inputs from data."""
|
||||
assert extract_inputs(Input("hello")) == {"hello"}
|
||||
assert extract_inputs({"info": [1, Input("hello"), 2, Input("world")]}) == {
|
||||
|
@ -18,7 +18,7 @@ def test_extract_inputs():
|
|||
}
|
||||
|
||||
|
||||
def test_substitute():
|
||||
def test_substitute() -> None:
|
||||
"""Test we can substitute."""
|
||||
assert substitute(Input("hello"), {"hello": 5}) == 5
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue