From 7027b01a29c428b0e60a7c1f1922e925746798f0 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 29 Oct 2020 22:34:06 +0100 Subject: [PATCH] Fix broken time trigger test (#42606) --- tests/components/config/test_core.py | 35 ++++++++++--------- tests/components/hassio/test_init.py | 3 +- .../homeassistant/triggers/test_time.py | 1 - 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/tests/components/config/test_core.py b/tests/components/config/test_core.py index 1f379727b44..72e655dbb66 100644 --- a/tests/components/config/test_core.py +++ b/tests/components/config/test_core.py @@ -61,22 +61,23 @@ async def test_websocket_core_update(hass, client): assert hass.config.external_url != "https://www.example.com" assert hass.config.internal_url != "http://example.com" - await client.send_json( - { - "id": 5, - "type": "config/core/update", - "latitude": 60, - "longitude": 50, - "elevation": 25, - "location_name": "Huis", - CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, - "time_zone": "America/New_York", - "external_url": "https://www.example.com", - "internal_url": "http://example.local", - } - ) + with patch("homeassistant.util.dt.set_default_time_zone") as mock_set_tz: + await client.send_json( + { + "id": 5, + "type": "config/core/update", + "latitude": 60, + "longitude": 50, + "elevation": 25, + "location_name": "Huis", + CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, + "time_zone": "America/New_York", + "external_url": "https://www.example.com", + "internal_url": "http://example.local", + } + ) - msg = await client.receive_json() + msg = await client.receive_json() assert msg["id"] == 5 assert msg["type"] == TYPE_RESULT @@ -86,11 +87,11 @@ async def test_websocket_core_update(hass, client): assert hass.config.elevation == 25 assert hass.config.location_name == "Huis" assert hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL - assert hass.config.time_zone.zone == "America/New_York" assert hass.config.external_url == "https://www.example.com" assert hass.config.internal_url == "http://example.local" - dt_util.set_default_time_zone(ORIG_TIME_ZONE) + assert len(mock_set_tz.mock_calls) == 1 + assert mock_set_tz.mock_calls[0][1][0].zone == "America/New_York" async def test_websocket_core_update_not_admin(hass, hass_ws_client, hass_admin_user): diff --git a/tests/components/hassio/test_init.py b/tests/components/hassio/test_init.py index 56792295fec..62b4a4adbd2 100644 --- a/tests/components/hassio/test_init.py +++ b/tests/components/hassio/test_init.py @@ -186,7 +186,8 @@ async def test_setup_core_push_timezone(hass, aioclient_mock): assert aioclient_mock.call_count == 7 assert aioclient_mock.mock_calls[2][2]["timezone"] == "testzone" - await hass.config.async_update(time_zone="America/New_York") + with patch("homeassistant.util.dt.set_default_time_zone"): + await hass.config.async_update(time_zone="America/New_York") await hass.async_block_till_done() assert aioclient_mock.mock_calls[-1][2]["timezone"] == "America/New_York" diff --git a/tests/components/homeassistant/triggers/test_time.py b/tests/components/homeassistant/triggers/test_time.py index db10e836629..91fd57beed3 100644 --- a/tests/components/homeassistant/triggers/test_time.py +++ b/tests/components/homeassistant/triggers/test_time.py @@ -74,7 +74,6 @@ async def test_if_fires_using_at_input_datetime(hass, calls, has_date, has_time) "input_datetime", {"input_datetime": {"trigger": {"has_date": has_date, "has_time": has_time}}}, ) - now = dt_util.now() trigger_dt = now.replace(