From 15b24dfbc2fd6ec912e4fffeb3efb357e99fa82d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 3 May 2024 13:28:36 +0200 Subject: [PATCH] Fix fyta test warning (#116688) --- tests/components/fyta/conftest.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/components/fyta/conftest.py b/tests/components/fyta/conftest.py index 9250c26926a..63af6340ade 100644 --- a/tests/components/fyta/conftest.py +++ b/tests/components/fyta/conftest.py @@ -1,6 +1,7 @@ """Test helpers.""" from collections.abc import Generator +from datetime import UTC, datetime, timedelta from unittest.mock import AsyncMock, patch import pytest @@ -32,14 +33,17 @@ def mock_fyta_init(): """Build a fixture for the Fyta API that connects successfully and returns one device.""" mock_fyta_api = AsyncMock() - with patch( - "homeassistant.components.fyta.FytaConnector", - return_value=mock_fyta_api, - ) as mock_fyta_api: - mock_fyta_api.return_value.login.return_value = { + mock_fyta_api.expiration = datetime.now(tz=UTC) + timedelta(days=1) + mock_fyta_api.login = AsyncMock( + return_value={ CONF_ACCESS_TOKEN: ACCESS_TOKEN, CONF_EXPIRATION: EXPIRATION, } + ) + with patch( + "homeassistant.components.fyta.FytaConnector.__new__", + return_value=mock_fyta_api, + ): yield mock_fyta_api