Fix fyta test warning (#116688)

This commit is contained in:
Marc Mueller 2024-05-03 13:28:36 +02:00 committed by GitHub
parent 217795865b
commit 15b24dfbc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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