diff --git a/tests/components/apache_kafka/test_init.py b/tests/components/apache_kafka/test_init.py index 45791da082e..ea62bb0569d 100644 --- a/tests/components/apache_kafka/test_init.py +++ b/tests/components/apache_kafka/test_init.py @@ -1,5 +1,7 @@ """The tests for the Apache Kafka component.""" -from collections import namedtuple +from asyncio import AbstractEventLoop +from dataclasses import dataclass +from typing import Callable, Type import pytest @@ -16,8 +18,23 @@ MIN_CONFIG = { "port": 8080, "topic": "topic", } -FilterTest = namedtuple("FilterTest", "id should_pass") -MockKafkaClient = namedtuple("MockKafkaClient", "init start send_and_wait") + + +@dataclass +class FilterTest: + """Class for capturing a filter test.""" + + id: str + should_pass: bool + + +@dataclass +class MockKafkaClient: + """Mock of the Apache Kafka client for testing.""" + + init: Callable[[Type[AbstractEventLoop], str, str], None] + start: Callable[[], None] + send_and_wait: Callable[[str, str], None] @pytest.fixture(name="mock_client") diff --git a/tests/components/azure_event_hub/test_init.py b/tests/components/azure_event_hub/test_init.py index bec710c5f3c..42bfefbcb3c 100644 --- a/tests/components/azure_event_hub/test_init.py +++ b/tests/components/azure_event_hub/test_init.py @@ -1,5 +1,5 @@ """The tests for the Azure Event Hub component.""" -from collections import namedtuple +from dataclasses import dataclass import pytest @@ -17,7 +17,14 @@ MIN_CONFIG = { "event_hub_sas_policy": "policy", "event_hub_sas_key": "key", } -FilterTest = namedtuple("FilterTest", "id should_pass") + + +@dataclass +class FilterTest: + """Class for capturing a filter test.""" + + id: str + should_pass: bool @pytest.fixture(autouse=True, name="mock_client", scope="module") diff --git a/tests/components/google_pubsub/test_init.py b/tests/components/google_pubsub/test_init.py index aebcfa06b13..96be5b3ed62 100644 --- a/tests/components/google_pubsub/test_init.py +++ b/tests/components/google_pubsub/test_init.py @@ -1,5 +1,5 @@ """The tests for the Google Pub/Sub component.""" -from collections import namedtuple +from dataclasses import dataclass from datetime import datetime import pytest @@ -15,6 +15,14 @@ import tests.async_mock as mock GOOGLE_PUBSUB_PATH = "homeassistant.components.google_pubsub" +@dataclass +class FilterTest: + """Class for capturing a filter test.""" + + id: str + should_pass: bool + + async def test_datetime(): """Test datetime encoding.""" time = datetime(2019, 1, 13, 12, 30, 5) @@ -109,9 +117,6 @@ async def test_full_config(hass, mock_client): ) -FilterTest = namedtuple("FilterTest", "id should_pass") - - def make_event(entity_id): """Make a mock event for test.""" domain = split_entity_id(entity_id)[0] diff --git a/tests/components/prometheus/test_init.py b/tests/components/prometheus/test_init.py index ca86658a88f..7b5f3182595 100644 --- a/tests/components/prometheus/test_init.py +++ b/tests/components/prometheus/test_init.py @@ -1,5 +1,5 @@ """The tests for the Prometheus exporter.""" -from collections import namedtuple +from dataclasses import dataclass import pytest @@ -22,6 +22,14 @@ import tests.async_mock as mock PROMETHEUS_PATH = "homeassistant.components.prometheus" +@dataclass +class FilterTest: + """Class for capturing a filter test.""" + + id: str + should_pass: bool + + @pytest.fixture async def prometheus_client(loop, hass, hass_client): """Initialize an hass_client with Prometheus component.""" @@ -202,9 +210,6 @@ async def test_full_config(hass, mock_client): assert EVENT_STATE_CHANGED == hass.bus.listen.call_args_list[0][0][0] -FilterTest = namedtuple("FilterTest", "id should_pass") - - def make_event(entity_id): """Make a mock event for test.""" domain = split_entity_id(entity_id)[0]