Skip to content

Commit

Permalink
Add return type to async tests without arguments (home-assistant#87612)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Feb 7, 2023
1 parent ea32a2a commit aa00114
Show file tree
Hide file tree
Showing 51 changed files with 117 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)


async def test_significant_change():
async def test_significant_change() -> None:
"""Detect NEW_NAME significant changes."""
attrs = {}
assert not async_check_significant_change(None, "on", attrs, "on", attrs)
Expand Down
2 changes: 1 addition & 1 deletion tests/auth/providers/test_homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def test_validating_password_invalid_user(data, hass):
data.validate_login("non-existing", "pw")


async def test_not_allow_set_id():
async def test_not_allow_set_id() -> None:
"""Test we are not allowed to set an ID in config."""
hass = Mock()
with pytest.raises(vol.Invalid):
Expand Down
2 changes: 1 addition & 1 deletion tests/components/auth/test_indieauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_parse_url_path():
assert indieauth._parse_url("http://ex.com").path == "/"


async def test_verify_redirect_uri():
async def test_verify_redirect_uri() -> None:
"""Test that we verify redirect uri correctly."""
assert await indieauth.verify_redirect_uri(
None, "http://ex.com", "http://ex.com/callback"
Expand Down
2 changes: 1 addition & 1 deletion tests/components/binary_sensor/test_significant_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)


async def test_significant_change():
async def test_significant_change() -> None:
"""Detect Binary Sensor significant changes."""
old_attrs = {"attr_1": "value_1"}
new_attrs = {"attr_1": "value_2"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def test_create_auth_system_generated_user(hass, hass_ws_client):
assert result["error"]["code"] == "system_generated"


async def test_create_auth_user_already_credentials():
async def test_create_auth_user_already_credentials() -> None:
"""Test we can't create auth for user with pre-existing credentials."""
# assert False

Expand Down
4 changes: 2 additions & 2 deletions tests/components/dialogflow/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@ def v2(self):
Data = _Data()


async def test_v1_data():
async def test_v1_data() -> None:
"""Test for version 1 api based on message."""
assert dialogflow.get_api_version(Data.v1) == 1


async def test_v2_data():
async def test_v2_data() -> None:
"""Test for version 2 api based on message."""
assert dialogflow.get_api_version(Data.v2) == 2

Expand Down
8 changes: 4 additions & 4 deletions tests/components/ecobee/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
from homeassistant.components.ecobee.util import ecobee_date, ecobee_time


async def test_ecobee_date_with_valid_input():
async def test_ecobee_date_with_valid_input() -> None:
"""Test that the date function returns the expected result."""
test_input = "2019-09-27"

assert ecobee_date(test_input) == test_input


async def test_ecobee_date_with_invalid_input():
async def test_ecobee_date_with_invalid_input() -> None:
"""Test that the date function raises the expected exception."""
test_input = "20190927"

with pytest.raises(vol.Invalid):
ecobee_date(test_input)


async def test_ecobee_time_with_valid_input():
async def test_ecobee_time_with_valid_input() -> None:
"""Test that the time function returns the expected result."""
test_input = "20:55:15"

assert ecobee_time(test_input) == test_input


async def test_ecobee_time_with_invalid_input():
async def test_ecobee_time_with_invalid_input() -> None:
"""Test that the time function raises the expected exception."""
test_input = "20:55"

Expand Down
2 changes: 1 addition & 1 deletion tests/components/google_assistant/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ async def _check_after_delay(data):
)


async def test_agent_user_id_connect():
async def test_agent_user_id_connect() -> None:
"""Test the connection and disconnection of users."""
config = MockConfig()
store = config._store
Expand Down
6 changes: 3 additions & 3 deletions tests/components/google_pubsub/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ class FilterTest:
should_pass: bool


async def test_datetime():
async def test_datetime() -> None:
"""Test datetime encoding."""
time = datetime(2019, 1, 13, 12, 30, 5)
assert victim().encode(time) == '"2019-01-13T12:30:05"'


async def test_no_datetime():
async def test_no_datetime() -> None:
"""Test integer encoding."""
assert victim().encode(42) == "42"


async def test_nested():
async def test_nested() -> None:
"""Test dictionary encoding."""
assert victim().encode({"foo": "bar"}) == '{"foo": "bar"}'

Expand Down
4 changes: 2 additions & 2 deletions tests/components/guardian/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ async def test_connect_error(hass, config):
assert result["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}


async def test_get_pin_from_discovery_hostname():
async def test_get_pin_from_discovery_hostname() -> None:
"""Test getting a device PIN from the zeroconf-discovered hostname."""
pin = async_get_pin_from_discovery_hostname("GVC1-3456.local.")
assert pin == "3456"


async def test_get_pin_from_uid():
async def test_get_pin_from_uid() -> None:
"""Test getting a device PIN from its UID."""
pin = async_get_pin_from_uid("ABCDEF123456")
assert pin == "3456"
Expand Down
6 changes: 3 additions & 3 deletions tests/components/homekit/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ async def test_port_is_available_skips_existing_entries(hass):
async_find_next_available_port(hass, 65530)


async def test_format_version():
async def test_format_version() -> None:
"""Test format_version method."""
assert format_version("soho+3.6.8+soho-release-rt120+10") == "3.6.8"
assert format_version("undefined-undefined-1.6.8") == "1.6.8"
Expand All @@ -362,14 +362,14 @@ async def test_format_version():
assert format_version("unknown") is None


async def test_coerce_int():
async def test_coerce_int() -> None:
"""Test coerce_int method."""
assert coerce_int("1") == 1
assert coerce_int("") == 0
assert coerce_int(0) == 0


async def test_accessory_friendly_name():
async def test_accessory_friendly_name() -> None:
"""Test we provide a helpful friendly name."""

accessory = Mock()
Expand Down
2 changes: 1 addition & 1 deletion tests/components/homematicip_cloud/test_hap.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def test_hap_setup_works(hass):
assert hap.home is home


async def test_hap_setup_connection_error():
async def test_hap_setup_connection_error() -> None:
"""Test a failed accesspoint setup."""
hass = Mock()
entry = Mock()
Expand Down
2 changes: 1 addition & 1 deletion tests/components/http/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def test_invalid_json(caplog):
)


async def test_nan_serialized_to_null():
async def test_nan_serialized_to_null() -> None:
"""Test nan serialized to null JSON."""
response = HomeAssistantView.json(float("NaN"))
assert json.loads(response.body.decode("utf-8")) is None
Expand Down
10 changes: 5 additions & 5 deletions tests/components/ipma/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from tests.common import MockConfigEntry, mock_registry


async def test_show_config_form():
async def test_show_config_form() -> None:
"""Test show configuration form."""
hass = Mock()
flow = config_flow.IpmaFlowHandler()
Expand All @@ -24,7 +24,7 @@ async def test_show_config_form():
assert result["step_id"] == "user"


async def test_show_config_form_default_values():
async def test_show_config_form_default_values() -> None:
"""Test show configuration form."""
hass = Mock()
flow = config_flow.IpmaFlowHandler()
Expand Down Expand Up @@ -54,7 +54,7 @@ async def test_flow_with_home_location(hass):
assert result["step_id"] == "user"


async def test_flow_show_form():
async def test_flow_show_form() -> None:
"""Test show form scenarios first time.
Test when the form should show when no configurations exists
Expand All @@ -70,7 +70,7 @@ async def test_flow_show_form():
assert len(config_form.mock_calls) == 1


async def test_flow_entry_created_from_user_input():
async def test_flow_entry_created_from_user_input() -> None:
"""Test that create data from user input.
Test when the form should show when no configurations exists
Expand All @@ -97,7 +97,7 @@ async def test_flow_entry_created_from_user_input():
assert not config_form.mock_calls


async def test_flow_entry_config_entry_already_exists():
async def test_flow_entry_config_entry_already_exists() -> None:
"""Test that create data from user input and config_entry already exists.
Test when the form should show when user puts existing name
Expand Down
2 changes: 1 addition & 1 deletion tests/components/light/test_significant_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
)


async def test_significant_change():
async def test_significant_change() -> None:
"""Detect Light significant changes."""
assert not async_check_significant_change(None, "on", {}, "on", {})
assert async_check_significant_change(None, "on", {}, "off", {})
Expand Down
2 changes: 1 addition & 1 deletion tests/components/lock/test_significant_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)


async def test_significant_change():
async def test_significant_change() -> None:
"""Detect Lock significant changes."""
old_attrs = {"attr_1": "a"}
new_attrs = {"attr_1": "b"}
Expand Down
6 changes: 3 additions & 3 deletions tests/components/media_source/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from homeassistant.setup import async_setup_component


async def test_is_media_source_id():
async def test_is_media_source_id() -> None:
"""Test media source validation."""
assert media_source.is_media_source_id(media_source.URI_SCHEME)
assert media_source.is_media_source_id(f"{media_source.URI_SCHEME}domain")
Expand All @@ -20,7 +20,7 @@ async def test_is_media_source_id():
assert not media_source.is_media_source_id("test")


async def test_generate_media_source_id():
async def test_generate_media_source_id() -> None:
"""Test identifier generation."""
tests = [
(None, None),
Expand Down Expand Up @@ -258,7 +258,7 @@ async def test_websocket_resolve_media(hass, hass_ws_client, filename):
assert msg["error"]["message"] == "test"


async def test_browse_resolve_without_setup():
async def test_browse_resolve_without_setup() -> None:
"""Test browse and resolve work without being setup."""
with pytest.raises(BrowseError):
await media_source.async_browse_media(Mock(data={}), None)
Expand Down
6 changes: 3 additions & 3 deletions tests/components/media_source/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from homeassistant.components.media_source import const, models


async def test_browse_media_as_dict():
async def test_browse_media_as_dict() -> None:
"""Test BrowseMediaSource conversion to media player item dict."""
base = models.BrowseMediaSource(
domain=const.DOMAIN,
Expand Down Expand Up @@ -40,7 +40,7 @@ async def test_browse_media_as_dict():
assert item["children"][0]["media_class"] == MediaClass.MUSIC


async def test_browse_media_parent_no_children():
async def test_browse_media_parent_no_children() -> None:
"""Test BrowseMediaSource conversion to media player item dict."""
base = models.BrowseMediaSource(
domain=const.DOMAIN,
Expand All @@ -63,7 +63,7 @@ async def test_browse_media_parent_no_children():
assert item["children_media_class"] is None


async def test_media_source_default_name():
async def test_media_source_default_name() -> None:
"""Test MediaSource uses domain as default name."""
source = models.MediaSource(const.DOMAIN)
assert source.name == const.DOMAIN
2 changes: 1 addition & 1 deletion tests/components/minio/test_minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def event_callback(event):
assert len(event.data["metadata"]) == 0


async def test_queue_listener():
async def test_queue_listener() -> None:
"""Tests QueueListener firing events on Home Assistant event bus."""
hass = MagicMock()

Expand Down
2 changes: 1 addition & 1 deletion tests/components/modbus/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def mock_modbus_with_pymodbus_fixture(hass, caplog, do_config, mock_pymodb
return mock_pymodbus


async def test_number_validator():
async def test_number_validator() -> None:
"""Test number validator."""

for value, value_type in (
Expand Down
2 changes: 1 addition & 1 deletion tests/components/mqtt/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def test_async_create_certificate_temp_files(
)


async def test_reading_non_exitisting_certificate_file():
async def test_reading_non_exitisting_certificate_file() -> None:
"""Test reading a non existing certificate file."""
assert (
mqtt.util.migrate_certificate_file_to_content("/home/file_not_exists") is None
Expand Down
4 changes: 2 additions & 2 deletions tests/components/nexia/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from homeassistant.components.nexia import util


async def test_is_invalid_auth_code():
async def test_is_invalid_auth_code() -> None:
"""Test for invalid auth."""

assert util.is_invalid_auth_code(HTTPStatus.UNAUTHORIZED) is True
assert util.is_invalid_auth_code(HTTPStatus.FORBIDDEN) is True
assert util.is_invalid_auth_code(HTTPStatus.NOT_FOUND) is False


async def test_percent_conv():
async def test_percent_conv() -> None:
"""Test percentage conversion."""

assert util.percent_conv(0.12) == 12.0
Expand Down
4 changes: 2 additions & 2 deletions tests/components/onboarding/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def test_setup_views_if_not_onboarded(hass):
assert not onboarding.async_is_onboarded(hass)


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


async def test_is_user_onboarded():
async def test_is_user_onboarded() -> None:
"""Test the is onboarded function."""
hass = Mock()
hass.data = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/components/person/test_significant_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)


async def test_significant_change():
async def test_significant_change() -> None:
"""Detect Person significant changes and ensure that attribute changes do not trigger a significant change."""
old_attrs = {"source": "device_tracker.wifi_device"}
new_attrs = {"source": "device_tracker.gps_device"}
Expand Down
Loading

0 comments on commit aa00114

Please sign in to comment.