From 857b5c9c1b78e2f79ea7c5a5f516b4ef5a40cd20 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 6 Jun 2024 12:19:41 +0200 Subject: [PATCH] Fix type hints in google tests (#118941) --- tests/components/google/conftest.py | 10 +++++----- tests/components/google/test_calendar.py | 10 ++++------ tests/components/google/test_diagnostics.py | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/components/google/conftest.py b/tests/components/google/conftest.py index d69770a9b0b..aff60ee0b04 100644 --- a/tests/components/google/conftest.py +++ b/tests/components/google/conftest.py @@ -92,14 +92,14 @@ CLIENT_ID = "client-id" CLIENT_SECRET = "client-secret" -@pytest.fixture(name="calendar_access_role") -def test_calendar_access_role() -> str: - """Default access role to use for test_api_calendar in tests.""" +@pytest.fixture +def calendar_access_role() -> str: + """Set default access role to use for test_api_calendar in tests.""" return "owner" -@pytest.fixture -def test_api_calendar(calendar_access_role: str) -> None: +@pytest.fixture(name="test_api_calendar") +def api_calendar(calendar_access_role: str) -> dict[str, Any]: """Return a test calendar object used in API responses.""" return { **TEST_API_CALENDAR, diff --git a/tests/components/google/test_calendar.py b/tests/components/google/test_calendar.py index 4f0e399bbbb..a5c65412c15 100644 --- a/tests/components/google/test_calendar.py +++ b/tests/components/google/test_calendar.py @@ -42,9 +42,9 @@ TEST_ENTITY_NAME = TEST_API_ENTITY_NAME @pytest.fixture(autouse=True) def mock_test_setup( - test_api_calendar, - mock_calendars_list, -): + test_api_calendar: dict[str, Any], + mock_calendars_list: ApiResult, +) -> None: """Fixture that sets up the default API responses during integration setup.""" mock_calendars_list({"items": [test_api_calendar]}) @@ -447,9 +447,7 @@ async def test_http_event_api_failure( hass: HomeAssistant, hass_client: ClientSessionGenerator, component_setup, - mock_calendars_list, mock_events_list, - aioclient_mock: AiohttpClientMocker, ) -> None: """Test the Rest API response during a calendar failure.""" mock_events_list({}, exc=ClientError()) @@ -570,7 +568,7 @@ async def test_opaque_event( async def test_scan_calendar_error( hass: HomeAssistant, component_setup, - mock_calendars_list, + mock_calendars_list: ApiResult, config_entry, ) -> None: """Test that the calendar update handles a server error.""" diff --git a/tests/components/google/test_diagnostics.py b/tests/components/google/test_diagnostics.py index 32ed2ab3224..69a1929b5ed 100644 --- a/tests/components/google/test_diagnostics.py +++ b/tests/components/google/test_diagnostics.py @@ -13,7 +13,7 @@ from homeassistant.auth.models import Credentials from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component -from .conftest import TEST_EVENT, ComponentSetup +from .conftest import TEST_EVENT, ApiResult, ComponentSetup from tests.common import CLIENT_ID, MockConfigEntry, MockUser from tests.components.diagnostics import get_diagnostics_for_config_entry @@ -23,9 +23,9 @@ from tests.typing import ClientSessionGenerator @pytest.fixture(autouse=True) def mock_test_setup( - test_api_calendar, - mock_calendars_list, -): + test_api_calendar: dict[str, Any], + mock_calendars_list: ApiResult, +) -> None: """Fixture that sets up the default API responses during integration setup.""" mock_calendars_list({"items": [test_api_calendar]})