Enable hass.io panel without ping (#22388)
* Enable hass.io panel without ping * fix tests
This commit is contained in:
parent
a27e821e8b
commit
3fddf5df08
3 changed files with 6 additions and 6 deletions
|
@ -145,8 +145,7 @@ async def async_setup(hass, config):
|
||||||
hass.data[DOMAIN] = hassio = HassIO(hass.loop, websession, host)
|
hass.data[DOMAIN] = hassio = HassIO(hass.loop, websession, host)
|
||||||
|
|
||||||
if not await hassio.is_connected():
|
if not await hassio.is_connected():
|
||||||
_LOGGER.error("Not connected with Hass.io")
|
_LOGGER.warning("Not connected with Hass.io / system to busy!")
|
||||||
return False
|
|
||||||
|
|
||||||
store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||||
data = await store.async_load()
|
data = await store.async_load()
|
||||||
|
|
|
@ -62,7 +62,7 @@ class HassIO:
|
||||||
|
|
||||||
This method return a coroutine.
|
This method return a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.send_command("/supervisor/ping", method="get")
|
return self.send_command("/supervisor/ping", method="get", timeout=15)
|
||||||
|
|
||||||
@_api_data
|
@_api_data
|
||||||
def get_homeassistant_info(self):
|
def get_homeassistant_info(self):
|
||||||
|
|
|
@ -219,15 +219,16 @@ def test_fail_setup_without_environ_var(hass):
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def test_fail_setup_cannot_connect(hass):
|
def test_fail_setup_cannot_connect(hass, caplog):
|
||||||
"""Fail setup if cannot connect."""
|
"""Fail setup if cannot connect."""
|
||||||
with patch.dict(os.environ, MOCK_ENVIRON), \
|
with patch.dict(os.environ, MOCK_ENVIRON), \
|
||||||
patch('homeassistant.components.hassio.HassIO.is_connected',
|
patch('homeassistant.components.hassio.HassIO.is_connected',
|
||||||
Mock(return_value=mock_coro(None))):
|
Mock(return_value=mock_coro(None))):
|
||||||
result = yield from async_setup_component(hass, 'hassio', {})
|
result = yield from async_setup_component(hass, 'hassio', {})
|
||||||
assert not result
|
assert result
|
||||||
|
|
||||||
assert not hass.components.hassio.is_hassio()
|
assert hass.components.hassio.is_hassio()
|
||||||
|
assert "Not connected with Hass.io / system to busy!" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue