Add a new mobile_app webhook command to get config (#22813)

* Add a new mobile_app webhook command to get config

* Limit fields returned
This commit is contained in:
Robbie Trencheny authored and Jason Hu committed 2019-04-07 01:16:54 -07:00
1 parent c8eebb6b4a
commit 3ce6be6297
3 files changed
+58 -6

No files matched your search

@@ -126,6 +126,40 @@ async def test_webhook_handle_get_zones(hass, create_registrations, # noqa: F40
assert json[0]['entity_id'] == 'zone.home'
async def test_webhook_handle_get_config(hass, create_registrations, # noqa: F401, F811, E501
webhook_client): # noqa: F811
"""Test that we can get config properly."""
resp = await webhook_client.post(
'/api/webhook/{}'.format(create_registrations[1]['webhook_id']),
json={'type': 'get_config'}
)
assert resp.status == 200
json = await resp.json()
if 'components' in json:
json['components'] = set(json['components'])
if 'whitelist_external_dirs' in json:
json['whitelist_external_dirs'] = \
set(json['whitelist_external_dirs'])
hass_config = hass.config.as_dict()
expected_dict = {
'latitude': hass_config['latitude'],
'longitude': hass_config['longitude'],
'elevation': hass_config['elevation'],
'unit_system': hass_config['unit_system'],
'location_name': hass_config['location_name'],
'time_zone': hass_config['time_zone'],
'components': hass_config['components'],
'version': hass_config['version'],
'theme_color': '#03A9F4', # Default frontend theme color
}
assert expected_dict == json
async def test_webhook_returns_error_incorrect_json(webhook_client, # noqa: F401, F811, E501
create_registrations, # noqa: F401, F811, E501
caplog): # noqa: E501 F811