Update hassbian component with real output (#5989)

This commit is contained in:
Paulus Schoutsen 2017-02-14 09:34:17 -08:00 committed by GitHub
parent 4b8e6e36b6
commit 409b74b780
2 changed files with 18 additions and 44 deletions

View File

@ -8,42 +8,26 @@ from homeassistant.components.http import HomeAssistantView
_TEST_OUTPUT = """ _TEST_OUTPUT = """
{ {
"suites": [ "suites":{
{ "libcec":{
"openzwave": [ "state":"Uninstalled",
{ "description":"Installs the libcec package for controlling CEC devices from this Pi"
"state": "installed"
}, },
{ "mosquitto":{
"description": "This is the description of the Open Z-Wave suite." "state":"failed",
} "description":"Installs the Mosquitto package for setting up a local MQTT server"
]
},
{
"openelec": [
{
"state": "not_installed"
}, },
{ "openzwave":{
"description": "state":"Uninstalled",
"OpenElec is amazing. It allows you to control the TV." "description":"Installs the Open Z-wave package for setting up your zwave network"
}
]
},
{
"mosquitto": [
{
"state": "installing"
}, },
{ "samba":{
"description": "state":"installing",
"Mosquitto is an MQTT broker." "description":"Installs the samba package for sharing the hassbian configuration files over the Pi's network."
} }
]
} }
]
} }
""" """ # noqa
@asyncio.coroutine @asyncio.coroutine
@ -87,18 +71,7 @@ class HassbianSuitesView(HomeAssistantView):
"""Request suite status.""" """Request suite status."""
inp = yield from hassbian_status(request.app['hass'], self._test_mode) inp = yield from hassbian_status(request.app['hass'], self._test_mode)
# Flatten the structure a bit return self.json(inp['suites'])
suites = {}
for suite in inp['suites']:
key = next(iter(suite))
info = suites[key] = {}
for item in suite[key]:
item_key = next(iter(item))
info[item_key] = item[item_key]
return self.json(suites)
class HassbianSuiteInstallView(HomeAssistantView): class HassbianSuiteInstallView(HomeAssistantView):

View File

@ -51,8 +51,9 @@ def test_get_suites(hass, test_client):
assert 'mosquitto' in result assert 'mosquitto' in result
info = result['mosquitto'] info = result['mosquitto']
assert info['state'] == 'installing' assert info['state'] == 'failed'
assert info['description'] == 'Mosquitto is an MQTT broker.' assert info['description'] == \
'Installs the Mosquitto package for setting up a local MQTT server'
@asyncio.coroutine @asyncio.coroutine