supervisor/tests/conftest.py
Pascal Vizeli 709f034f2e
New TimeZone handling (#1138)
* Remove function to get TZ from config file

* Readd old timezone handling

* Fix tests
2019-06-25 17:09:14 +02:00

46 lines
1.1 KiB
Python

"""Common test functions."""
from unittest.mock import patch, PropertyMock, MagicMock
import pytest
from hassio.bootstrap import initialize_coresys
from tests.common import mock_coro
# pylint: disable=redefined-outer-name
@pytest.fixture
def docker():
"""Mock Docker API."""
with patch("hassio.coresys.DockerAPI") as mock:
yield mock
@pytest.fixture
async def coresys(loop, docker):
"""Create a CoreSys Mock."""
with patch("hassio.bootstrap.initialize_system_data"), patch(
"hassio.bootstrap.fetch_timezone",
return_value=mock_coro(return_value="Europe/Zurich"),
):
coresys_obj = await initialize_coresys()
coresys_obj.ingress.save_data = MagicMock()
yield coresys_obj
@pytest.fixture
def sys_machine():
"""Mock sys_machine."""
with patch("hassio.coresys.CoreSys.machine", new_callable=PropertyMock) as mock:
yield mock
@pytest.fixture
def sys_supervisor():
with patch("hassio.coresys.CoreSys.supervisor", new_callable=PropertyMock) as mock:
mock.return_value = MagicMock()
yield MagicMock