mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Fix dangerous-default-value warnings in automation tests (#119576)
This commit is contained in:
parent
cadb6317bf
commit
b2be3e0a9b
@ -4,6 +4,7 @@ import asyncio
|
|||||||
import contextlib
|
import contextlib
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -56,12 +57,12 @@ async def test_notify_leaving_zone(
|
|||||||
connections={(dr.CONNECTION_NETWORK_MAC, "00:00:00:00:00:01")},
|
connections={(dr.CONNECTION_NETWORK_MAC, "00:00:00:00:00:01")},
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_person_state(state, extra={}):
|
def set_person_state(state: str, extra: dict[str, Any]) -> None:
|
||||||
hass.states.async_set(
|
hass.states.async_set(
|
||||||
"person.test_person", state, {"friendly_name": "Paulus", **extra}
|
"person.test_person", state, {"friendly_name": "Paulus", **extra}
|
||||||
)
|
)
|
||||||
|
|
||||||
set_person_state("School")
|
set_person_state("School", {})
|
||||||
|
|
||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass, "zone", {"zone": {"name": "School", "latitude": 1, "longitude": 2}}
|
hass, "zone", {"zone": {"name": "School", "latitude": 1, "longitude": 2}}
|
||||||
@ -92,7 +93,7 @@ async def test_notify_leaving_zone(
|
|||||||
"homeassistant.components.mobile_app.device_action.async_call_action_from_config"
|
"homeassistant.components.mobile_app.device_action.async_call_action_from_config"
|
||||||
) as mock_call_action:
|
) as mock_call_action:
|
||||||
# Leaving zone to no zone
|
# Leaving zone to no zone
|
||||||
set_person_state("not_home")
|
set_person_state("not_home", {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_call_action.mock_calls) == 1
|
assert len(mock_call_action.mock_calls) == 1
|
||||||
@ -108,13 +109,13 @@ async def test_notify_leaving_zone(
|
|||||||
assert message_tpl.async_render(variables) == "Paulus has left School"
|
assert message_tpl.async_render(variables) == "Paulus has left School"
|
||||||
|
|
||||||
# Should not increase when we go to another zone
|
# Should not increase when we go to another zone
|
||||||
set_person_state("bla")
|
set_person_state("bla", {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_call_action.mock_calls) == 1
|
assert len(mock_call_action.mock_calls) == 1
|
||||||
|
|
||||||
# Should not increase when we go into the zone
|
# Should not increase when we go into the zone
|
||||||
set_person_state("School")
|
set_person_state("School", {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_call_action.mock_calls) == 1
|
assert len(mock_call_action.mock_calls) == 1
|
||||||
@ -126,7 +127,7 @@ async def test_notify_leaving_zone(
|
|||||||
assert len(mock_call_action.mock_calls) == 1
|
assert len(mock_call_action.mock_calls) == 1
|
||||||
|
|
||||||
# Should increase when leaving zone for another zone
|
# Should increase when leaving zone for another zone
|
||||||
set_person_state("Just Outside School")
|
set_person_state("Just Outside School", {})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(mock_call_action.mock_calls) == 2
|
assert len(mock_call_action.mock_calls) == 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user