1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-25 09:49:52 +01:00
Files
core/tests/components/voip/test_switch.py
T
Jamin 6f3dfab487 Voip runtime data (#170765)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2026-05-18 19:40:30 +02:00

56 lines
1.5 KiB
Python

"""Test VoIP switch devices."""
from homeassistant.components.voip.devices import VoIPDevice
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def test_allow_call(
hass: HomeAssistant,
setup_voip: None,
config_entry: MockConfigEntry,
voip_device: VoIPDevice,
) -> None:
"""Test allow call."""
assert not voip_device.async_allow_call(hass)
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state is not None
assert state.state == "off"
await hass.config_entries.async_reload(config_entry.entry_id)
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state.state == "off"
await hass.services.async_call(
"switch",
"turn_on",
{"entity_id": "switch.192_168_1_210_allow_calls"},
blocking=True,
)
assert voip_device.async_allow_call(hass)
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state.state == "on"
await hass.config_entries.async_reload(config_entry.entry_id)
await hass.async_block_till_done()
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state.state == "on"
await hass.services.async_call(
"switch",
"turn_off",
{"entity_id": "switch.192_168_1_210_allow_calls"},
blocking=True,
)
assert not voip_device.async_allow_call(hass)
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state.state == "off"