mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-10 02:36:29 +00:00
Skip plugin update on startup if supervisor out of date (#4515)
This commit is contained in:
parent
4838b280ad
commit
f4b43739da
@ -135,10 +135,10 @@ class Core(CoreSysAttributes):
|
||||
self.sys_mounts.load(),
|
||||
# Load Docker manager
|
||||
self.sys_docker.load(),
|
||||
# Load Plugins container
|
||||
self.sys_plugins.load(),
|
||||
# load last available data
|
||||
self.sys_updater.load(),
|
||||
# Load Plugins container
|
||||
self.sys_plugins.load(),
|
||||
# Load Home Assistant
|
||||
self.sys_homeassistant.load(),
|
||||
# Load CPU/Arch
|
||||
|
@ -75,8 +75,11 @@ class PluginManager(CoreSysAttributes):
|
||||
)
|
||||
capture_exception(err)
|
||||
|
||||
# Exit if supervisor out of date. Plugins can't update until then
|
||||
if self.sys_supervisor.need_update:
|
||||
return
|
||||
|
||||
# Check requirements
|
||||
await self.sys_updater.reload()
|
||||
for plugin in self.all_plugins:
|
||||
# Check if need an update
|
||||
if not plugin.need_update:
|
||||
|
@ -1,9 +1,13 @@
|
||||
"""Test plugin manager."""
|
||||
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import PropertyMock, patch
|
||||
|
||||
from awesomeversion import AwesomeVersion
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.docker.interface import DockerInterface
|
||||
from supervisor.plugins.base import PluginBase
|
||||
from supervisor.supervisor import Supervisor
|
||||
|
||||
|
||||
def mock_awaitable_bool(value: bool):
|
||||
@ -29,3 +33,30 @@ async def test_repair(coresys: CoreSys):
|
||||
await coresys.plugins.repair()
|
||||
|
||||
assert install.call_count == len(coresys.plugins.all_plugins)
|
||||
|
||||
|
||||
async def test_load(coresys: CoreSys):
|
||||
"""Test plugin manager load."""
|
||||
coresys.hardware.disk.get_disk_free_space = lambda x: 5000
|
||||
await coresys.updater.load()
|
||||
|
||||
need_update = PropertyMock(return_value=True)
|
||||
with patch.object(DockerInterface, "attach") as attach, patch.object(
|
||||
DockerInterface, "update"
|
||||
) as update, patch.object(Supervisor, "need_update", new=need_update), patch.object(
|
||||
PluginBase, "need_update", new=PropertyMock(return_value=True)
|
||||
), patch.object(
|
||||
PluginBase,
|
||||
"version",
|
||||
new=PropertyMock(return_value=AwesomeVersion("1970-01-01")),
|
||||
):
|
||||
await coresys.plugins.load()
|
||||
|
||||
assert attach.call_count == 5
|
||||
update.assert_not_called()
|
||||
|
||||
need_update.return_value = False
|
||||
await coresys.plugins.load()
|
||||
|
||||
assert attach.call_count == 10
|
||||
assert update.call_count == 5
|
||||
|
Loading…
x
Reference in New Issue
Block a user