Add type hints to integration tests (part 15) (#88006)

This commit is contained in:
epenet 2023-02-15 10:00:49 +01:00 committed by GitHub
parent 6c23d6abfe
commit 50cbabb2d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 896 additions and 427 deletions

View file

@ -1,5 +1,6 @@
"""The tests for notify services that change targets."""
import asyncio
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
@ -38,7 +39,7 @@ def mock_notify_platform(
return loaded_platform
async def test_same_targets(hass: HomeAssistant):
async def test_same_targets(hass: HomeAssistant) -> None:
"""Test not changing the targets in a notify service."""
test = NotificationService(hass)
await test.async_setup(hass, "notify", "test")
@ -53,7 +54,7 @@ async def test_same_targets(hass: HomeAssistant):
assert test.registered_targets == {"test_a": 1, "test_b": 2}
async def test_change_targets(hass: HomeAssistant):
async def test_change_targets(hass: HomeAssistant) -> None:
"""Test changing the targets in a notify service."""
test = NotificationService(hass)
await test.async_setup(hass, "notify", "test")
@ -70,7 +71,7 @@ async def test_change_targets(hass: HomeAssistant):
assert test.registered_targets == {"test_a": 0}
async def test_add_targets(hass: HomeAssistant):
async def test_add_targets(hass: HomeAssistant) -> None:
"""Test adding the targets in a notify service."""
test = NotificationService(hass)
await test.async_setup(hass, "notify", "test")
@ -87,7 +88,7 @@ async def test_add_targets(hass: HomeAssistant):
assert test.registered_targets == {"test_a": 1, "test_b": 2, "test_c": 3}
async def test_remove_targets(hass: HomeAssistant):
async def test_remove_targets(hass: HomeAssistant) -> None:
"""Test removing targets from the targets in a notify service."""
test = NotificationService(hass)
await test.async_setup(hass, "notify", "test")
@ -141,7 +142,9 @@ async def test_warn_template(
assert hass.states.get("persistent_notification.notification") is not None
async def test_invalid_platform(hass, caplog, tmp_path):
async def test_invalid_platform(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test service setup with an invalid platform."""
mock_notify_platform(hass, tmp_path, "testnotify1")
# Setup the platform
@ -164,7 +167,9 @@ async def test_invalid_platform(hass, caplog, tmp_path):
assert "Invalid notify platform" in caplog.text
async def test_invalid_service(hass, caplog, tmp_path):
async def test_invalid_service(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test service setup with an invalid service object or platform."""
def get_service(hass, config, discovery_info=None):
@ -195,7 +200,9 @@ async def test_invalid_service(hass, caplog, tmp_path):
assert "Unknown notification service specified" in caplog.text
async def test_platform_setup_with_error(hass, caplog, tmp_path):
async def test_platform_setup_with_error(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test service setup with an invalid setup."""
async def async_get_service(hass, config, discovery_info=None):
@ -217,7 +224,9 @@ async def test_platform_setup_with_error(hass, caplog, tmp_path):
assert "Error setting up platform testnotify" in caplog.text
async def test_reload_with_notify_builtin_platform_reload(hass, caplog, tmp_path):
async def test_reload_with_notify_builtin_platform_reload(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test reload using the notify platform reload method."""
async def async_get_service(hass, config, discovery_info=None):
@ -247,7 +256,9 @@ async def test_reload_with_notify_builtin_platform_reload(hass, caplog, tmp_path
assert hass.services.has_service(notify.DOMAIN, "testnotify_b")
async def test_setup_platform_and_reload(hass, caplog, tmp_path):
async def test_setup_platform_and_reload(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test service setup and reload."""
get_service_called = Mock()
@ -335,7 +346,9 @@ async def test_setup_platform_and_reload(hass, caplog, tmp_path):
assert not hass.services.has_service(notify.DOMAIN, "testnotify2_d")
async def test_setup_platform_before_notify_setup(hass, caplog, tmp_path):
async def test_setup_platform_before_notify_setup(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test trying to setup a platform before notify is setup."""
get_service_called = Mock()
@ -383,7 +396,9 @@ async def test_setup_platform_before_notify_setup(hass, caplog, tmp_path):
assert hass.services.has_service(notify.DOMAIN, "testnotify2_d")
async def test_setup_platform_after_notify_setup(hass, caplog, tmp_path):
async def test_setup_platform_after_notify_setup(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, tmp_path: Path
) -> None:
"""Test trying to setup a platform after notify is setup."""
get_service_called = Mock()