Fix broken time trigger test (#42606)

pull/42584/head
Paulus Schoutsen 2020-10-29 22:34:06 +01:00 committed by GitHub
parent 1215100f9a
commit 7027b01a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 19 deletions

View File

@ -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):

View File

@ -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"

View File

@ -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(