mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-04-17 23:33:35 +01:00
New TimeZone handling (#1138)
* Remove function to get TZ from config file * Readd old timezone handling * Fix tests
This commit is contained in:
@@ -7,3 +7,20 @@ def load_json_fixture(filename):
|
||||
"""Load a fixture."""
|
||||
path = Path(Path(__file__).parent.joinpath("fixtures"), filename)
|
||||
return json.loads(path.read_text())
|
||||
|
||||
|
||||
def mock_coro(return_value=None, exception=None):
|
||||
"""Return a coro that returns a value or raise an exception."""
|
||||
return mock_coro_func(return_value, exception)()
|
||||
|
||||
|
||||
def mock_coro_func(return_value=None, exception=None):
|
||||
"""Return a method to create a coro function that returns a value."""
|
||||
|
||||
async def coro(*args, **kwargs):
|
||||
"""Fake coroutine."""
|
||||
if exception:
|
||||
raise exception
|
||||
return return_value
|
||||
|
||||
return coro
|
||||
|
||||
@@ -5,6 +5,8 @@ import pytest
|
||||
|
||||
from hassio.bootstrap import initialize_coresys
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
|
||||
|
||||
@@ -18,7 +20,10 @@ def docker():
|
||||
@pytest.fixture
|
||||
async def coresys(loop, docker):
|
||||
"""Create a CoreSys Mock."""
|
||||
with patch("hassio.bootstrap.initialize_system_data"):
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user