Cloud conf (#18216)
* Add original config to entityfilter * Add alexa/google config to cloud status call * Lint
This commit is contained in:
1 parent
8de79ed57c
commit
bf54582d76
5 files changed
+74
-20
No files matched your search
@@ -35,6 +35,16 @@ def setup_api(hass):
|
||||
'relayer': 'relayer',
|
||||
'google_actions_sync_url': GOOGLE_ACTIONS_SYNC_URL,
|
||||
'subscription_info_url': SUBSCRIPTION_INFO_URL,
|
||||
'google_actions': {
|
||||
'filter': {
|
||||
'include_domains': 'light'
|
||||
}
|
||||
},
|
||||
'alexa': {
|
||||
'filter': {
|
||||
'include_entities': ['light.kitchen', 'switch.ac']
|
||||
}
|
||||
}
|
||||
})
|
||||
return mock_cloud_prefs(hass)
|
||||
|
||||
@@ -325,17 +335,37 @@ async def test_websocket_status(hass, hass_ws_client, mock_cloud_fixture):
|
||||
}, 'test')
|
||||
hass.data[DOMAIN].iot.state = iot.STATE_CONNECTED
|
||||
client = await hass_ws_client(hass)
|
||||
await client.send_json({
|
||||
'id': 5,
|
||||
'type': 'cloud/status'
|
||||
})
|
||||
response = await client.receive_json()
|
||||
|
||||
with patch.dict(
|
||||
'homeassistant.components.google_assistant.smart_home.'
|
||||
'DOMAIN_TO_GOOGLE_TYPES', {'light': None}, clear=True
|
||||
), patch.dict('homeassistant.components.alexa.smart_home.ENTITY_ADAPTERS',
|
||||
{'switch': None}, clear=True):
|
||||
await client.send_json({
|
||||
'id': 5,
|
||||
'type': 'cloud/status'
|
||||
})
|
||||
response = await client.receive_json()
|
||||
assert response['result'] == {
|
||||
'logged_in': True,
|
||||
'email': 'hello@home-assistant.io',
|
||||
'cloud': 'connected',
|
||||
'alexa_enabled': True,
|
||||
'alexa_entities': {
|
||||
'include_domains': [],
|
||||
'include_entities': ['light.kitchen', 'switch.ac'],
|
||||
'exclude_domains': [],
|
||||
'exclude_entities': [],
|
||||
},
|
||||
'alexa_domains': ['switch'],
|
||||
'google_enabled': True,
|
||||
'google_entities': {
|
||||
'include_domains': ['light'],
|
||||
'include_entities': [],
|
||||
'exclude_domains': [],
|
||||
'exclude_entities': [],
|
||||
},
|
||||
'google_domains': ['light'],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""The tests for the EntityFilter component."""
|
||||
from homeassistant.helpers.entityfilter import generate_filter
|
||||
from homeassistant.helpers.entityfilter import generate_filter, FILTER_SCHEMA
|
||||
|
||||
|
||||
def test_no_filters_case_1():
|
||||
@@ -78,7 +78,7 @@ def test_exclude_domain_case4b():
|
||||
assert testfilter("sun.sun") is True
|
||||
|
||||
|
||||
def testno_domain_case4c():
|
||||
def test_no_domain_case4c():
|
||||
"""Test case 4c - include and exclude specified, with no domains."""
|
||||
incl_dom = {}
|
||||
incl_ent = {'binary_sensor.working'}
|
||||
@@ -93,3 +93,15 @@ def testno_domain_case4c():
|
||||
assert testfilter("binary_sensor.working")
|
||||
assert testfilter("binary_sensor.another") is False
|
||||
assert testfilter("sun.sun") is False
|
||||
|
||||
|
||||
def test_filter_schema():
|
||||
"""Test filter schema."""
|
||||
conf = {
|
||||
'include_domains': ['light'],
|
||||
'include_entities': ['switch.kitchen'],
|
||||
'exclude_domains': ['cover'],
|
||||
'exclude_entities': ['light.kitchen']
|
||||
}
|
||||
filt = FILTER_SCHEMA(conf)
|
||||
assert filt.config == conf
|
||||
Reference in new issue
Block a user