Set up Almond Web to connect to HA (#28603)
* Set up Almond Web to connect to HA * Add missing string * Add type
This commit is contained in:
parent
a1f2b6d402
commit
5961215e6e
5 changed files with 245 additions and 14 deletions
34
tests/helpers/test_network.py
Normal file
34
tests/helpers/test_network.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""Test network helper."""
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.helpers import network
|
||||
from homeassistant.components import cloud
|
||||
|
||||
|
||||
async def test_get_external_url(hass):
|
||||
"""Test get_external_url."""
|
||||
hass.config.api = Mock(base_url="http://192.168.1.100:8123")
|
||||
|
||||
assert network.async_get_external_url(hass) is None
|
||||
|
||||
hass.config.api = Mock(base_url="http://example.duckdns.org:8123")
|
||||
|
||||
assert network.async_get_external_url(hass) == "http://example.duckdns.org:8123"
|
||||
|
||||
hass.config.components.add("cloud")
|
||||
|
||||
assert network.async_get_external_url(hass) == "http://example.duckdns.org:8123"
|
||||
|
||||
with patch.object(
|
||||
hass.components.cloud,
|
||||
"async_remote_ui_url",
|
||||
side_effect=cloud.CloudNotAvailable,
|
||||
):
|
||||
assert network.async_get_external_url(hass) == "http://example.duckdns.org:8123"
|
||||
|
||||
with patch.object(
|
||||
hass.components.cloud,
|
||||
"async_remote_ui_url",
|
||||
return_value="https://example.nabu.casa",
|
||||
):
|
||||
assert network.async_get_external_url(hass) == "https://example.nabu.casa"
|
Loading…
Add table
Add a link
Reference in a new issue