1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-24 20:35:55 +00:00

Use add-on config timestamp to determine add-on update age (#5897)

* Use add-on config timestamp to determine add-on update age

Instead of using the current timestamp when loading the add-on config,
simply use the add-on config modification timestamp. This way, we can
get a timetsamp even when Supervisor got restarted. It also simplifies
the code a bit.

* Fix pytest

* Patch stat() instead of modifing fixture files
This commit is contained in:
Stefan Agner
2025-05-21 13:46:20 +02:00
committed by GitHub
parent 86c016b35d
commit 1faf529b42
4 changed files with 34 additions and 34 deletions

View File

@@ -1,5 +1,7 @@
"""Test store manager."""
from datetime import datetime
from types import SimpleNamespace
from typing import Any
from unittest.mock import PropertyMock, patch
@@ -251,7 +253,11 @@ async def test_addon_version_timestamp(coresys: CoreSys, install_addon_example:
# If a new version is seen processing repo, reset to utc now
install_addon_example.data_store["version"] = "1.1.0"
# Signal the store repositories got updated
with patch("supervisor.store.repository.Repository.update", return_value=True):
with patch(
"pathlib.Path.stat",
return_value=SimpleNamespace(
st_mode=0o100644, st_mtime=datetime.now().timestamp()
),
):
await coresys.store.reload()
assert timestamp < install_addon_example.latest_version_timestamp
assert timestamp < install_addon_example.latest_version_timestamp