mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-24 02:07:06 +00:00
Update to python 3.11 (#4296)
This commit is contained in:
31
tests/plugins/test_plugin_manager.py
Normal file
31
tests/plugins/test_plugin_manager.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Test plugin manager."""
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from supervisor.coresys import CoreSys
|
||||
from supervisor.docker.interface import DockerInterface
|
||||
|
||||
|
||||
def mock_awaitable_bool(value: bool):
|
||||
"""Return a mock of an awaitable bool."""
|
||||
|
||||
async def _mock_bool(*args, **kwargs) -> bool:
|
||||
return value
|
||||
|
||||
return _mock_bool
|
||||
|
||||
|
||||
async def test_repair(coresys: CoreSys):
|
||||
"""Test repair."""
|
||||
with patch.object(DockerInterface, "install") as install:
|
||||
# If instance exists, repair does nothing
|
||||
with patch.object(DockerInterface, "exists", new=mock_awaitable_bool(True)):
|
||||
await coresys.plugins.repair()
|
||||
|
||||
install.assert_not_called()
|
||||
|
||||
# If not, repair installs the image
|
||||
with patch.object(DockerInterface, "exists", new=mock_awaitable_bool(False)):
|
||||
await coresys.plugins.repair()
|
||||
|
||||
assert install.call_count == len(coresys.plugins.all_plugins)
|
||||
Reference in New Issue
Block a user