mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-04-23 04:37:15 +00:00

* Sanitise event * No need to remove supervisor token * cleanup * Typo * Review comments * Move and test * Move and use hdr
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
"""Common test functions."""
|
|
from unittest.mock import MagicMock, PropertyMock, patch
|
|
|
|
import pytest
|
|
|
|
from supervisor.bootstrap import initialize_coresys
|
|
|
|
# pylint: disable=redefined-outer-name, protected-access
|
|
|
|
|
|
@pytest.fixture
|
|
def docker():
|
|
"""Mock Docker API."""
|
|
with patch("supervisor.coresys.DockerAPI") as mock:
|
|
yield mock
|
|
|
|
|
|
@pytest.fixture
|
|
async def coresys(loop, docker):
|
|
"""Create a CoreSys Mock."""
|
|
with patch("supervisor.bootstrap.initialize_system_data"), patch(
|
|
"supervisor.bootstrap.setup_diagnostics"
|
|
), patch(
|
|
"supervisor.bootstrap.fetch_timezone", return_value="Europe/Zurich",
|
|
):
|
|
coresys_obj = await initialize_coresys()
|
|
|
|
coresys_obj.ingress.save_data = MagicMock()
|
|
coresys_obj.arch._default_arch = "amd64"
|
|
|
|
yield coresys_obj
|
|
|
|
|
|
@pytest.fixture
|
|
def sys_machine():
|
|
"""Mock sys_machine."""
|
|
with patch("supervisor.coresys.CoreSys.machine", new_callable=PropertyMock) as mock:
|
|
yield mock
|
|
|
|
|
|
@pytest.fixture
|
|
def sys_supervisor():
|
|
"""Mock sys_supervisor."""
|
|
with patch(
|
|
"supervisor.coresys.CoreSys.supervisor", new_callable=PropertyMock
|
|
) as mock:
|
|
mock.return_value = MagicMock()
|
|
yield MagicMock
|