Update mock token last_access to a fixed UTC datetime in ntfy tests (#177896)

This commit is contained in:
Manu
2026-08-01 01:51:33 +02:00
committed by GitHub
parent 2a542f36fc
commit 8c9eed6599
2 changed files with 6 additions and 11 deletions
+1 -2
View File
@@ -45,8 +45,7 @@ def mock_aiontfy() -> Generator[AsyncMock]:
load_fixture("account.json", DOMAIN)
)
client.generate_token.return_value = AccountTokenResponse(
token="token",
last_access=datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
token="token", last_access=datetime(1970, 1, 1, 0, 0, 0, tzinfo=UTC)
)
client.version.return_value = Version.from_json(
load_fixture("version.json", DOMAIN)
+5 -9
View File
@@ -1,6 +1,6 @@
"""Test the ntfy config flow."""
from datetime import datetime
from datetime import UTC, datetime
from typing import Any
from unittest.mock import AsyncMock
@@ -450,8 +450,7 @@ async def test_flow_reauth(
},
)
mock_aiontfy.generate_token.return_value = AccountTokenResponse(
token="newtoken",
last_access=datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
token="newtoken", last_access=datetime(1970, 1, 1, 0, 0, 0, tzinfo=UTC)
)
config_entry.add_to_hass(hass)
result = await config_entry.start_reauth_flow(hass)
@@ -510,8 +509,7 @@ async def test_form_reauth_errors(
)
mock_aiontfy.account.side_effect = exception
mock_aiontfy.generate_token.return_value = AccountTokenResponse(
token="newtoken",
last_access=datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
token="newtoken", last_access=datetime(1970, 1, 1, 0, 0, 0, tzinfo=UTC)
)
config_entry.add_to_hass(hass)
result = await config_entry.start_reauth_flow(hass)
@@ -597,8 +595,7 @@ async def test_flow_reconfigure(
},
)
mock_aiontfy.generate_token.return_value = AccountTokenResponse(
token="newtoken",
last_access=datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
token="newtoken", last_access=datetime(1970, 1, 1, 0, 0, 0, tzinfo=UTC)
)
config_entry.add_to_hass(hass)
result = await config_entry.start_reconfigure_flow(hass)
@@ -700,8 +697,7 @@ async def test_flow_reconfigure_errors(
},
)
mock_aiontfy.generate_token.return_value = AccountTokenResponse(
token="newtoken",
last_access=datetime.now(), # pylint: disable=home-assistant-enforce-naive-now
token="newtoken", last_access=datetime(1970, 1, 1, 0, 0, 0, tzinfo=UTC)
)
mock_aiontfy.account.side_effect = exception