core/tests/components/voip/test_switch.py
Paulus Schoutsen 0678ab4e45
Add VoIP entities (#91320)
* WIP

* Add VoIP entities to enable calls

* Mark voip entities as config only

* Remove commented code
2023-04-12 23:23:20 -04:00

41 lines
1.1 KiB
Python

"""Test VoIP switch devices."""
from __future__ import annotations
from homeassistant.core import HomeAssistant
async def test_allow_call(
hass: HomeAssistant, config_entry, voip_devices, call_info
) -> None:
"""Test allow call."""
assert not voip_devices.async_allow_call(call_info)
await hass.async_block_till_done()
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_devices.async_allow_call(call_info)
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)
state = hass.states.get("switch.192_168_1_210_allow_calls")
assert state is not None
assert state.state == "on"