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:
Paulus Schoutsen 2019-11-12 11:01:19 -08:00 committed by GitHub
parent a1f2b6d402
commit 5961215e6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 245 additions and 14 deletions

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