Add return type to tests without arguments (#87613)

* Add return type to tests without arguments

* Black

* Cancel fixture amends
This commit is contained in:
epenet 2023-02-07 14:20:06 +01:00 committed by GitHub
parent fb4c0b4b7a
commit 4142f0d15d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 473 additions and 459 deletions

View file

@ -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)