Import homeassistant domain instead of hardcoding it (#17985)

This commit is contained in:
Ville Skyttä authored and GitHub committed 2018-10-30 17:38:09 +02:00
1 parent 87bd2a32e4
commit 4d9ef9e795
5 files changed
+35 -34

No files matched your search

+9 -8
View File
@@ -2,6 +2,7 @@
# pylint: disable=protected-access
import pytest
from homeassistant.core import DOMAIN as HASS_DOMAIN
from homeassistant.setup import async_setup_component
from homeassistant.components import conversation
import homeassistant.components as component
@@ -152,7 +153,7 @@ async def test_turn_on_intent(hass, sentence):
assert result
hass.states.async_set('light.kitchen', 'off')
calls = async_mock_service(hass, 'homeassistant', 'turn_on')
calls = async_mock_service(hass, HASS_DOMAIN, 'turn_on')
await hass.services.async_call(
'conversation', 'process', {
@@ -162,7 +163,7 @@ async def test_turn_on_intent(hass, sentence):
assert len(calls) == 1
call = calls[0]
assert call.domain == 'homeassistant'
assert call.domain == HASS_DOMAIN
assert call.service == 'turn_on'
assert call.data == {'entity_id': 'light.kitchen'}
@@ -203,7 +204,7 @@ async def test_turn_off_intent(hass, sentence):
assert result
hass.states.async_set('light.kitchen', 'on')
calls = async_mock_service(hass, 'homeassistant', 'turn_off')
calls = async_mock_service(hass, HASS_DOMAIN, 'turn_off')
await hass.services.async_call(
'conversation', 'process', {
@@ -213,7 +214,7 @@ async def test_turn_off_intent(hass, sentence):
assert len(calls) == 1
call = calls[0]
assert call.domain == 'homeassistant'
assert call.domain == HASS_DOMAIN
assert call.service == 'turn_off'
assert call.data == {'entity_id': 'light.kitchen'}
@@ -228,7 +229,7 @@ async def test_toggle_intent(hass, sentence):
assert result
hass.states.async_set('light.kitchen', 'on')
calls = async_mock_service(hass, 'homeassistant', 'toggle')
calls = async_mock_service(hass, HASS_DOMAIN, 'toggle')
await hass.services.async_call(
'conversation', 'process', {
@@ -238,7 +239,7 @@ async def test_toggle_intent(hass, sentence):
assert len(calls) == 1
call = calls[0]
assert call.domain == 'homeassistant'
assert call.domain == HASS_DOMAIN
assert call.service == 'toggle'
assert call.data == {'entity_id': 'light.kitchen'}
@@ -253,7 +254,7 @@ async def test_http_api(hass, aiohttp_client):
client = await aiohttp_client(hass.http.app)
hass.states.async_set('light.kitchen', 'off')
calls = async_mock_service(hass, 'homeassistant', 'turn_on')
calls = async_mock_service(hass, HASS_DOMAIN, 'turn_on')
resp = await client.post('/api/conversation/process', json={
'text': 'Turn the kitchen on'
@@ -262,7 +263,7 @@ async def test_http_api(hass, aiohttp_client):
assert len(calls) == 1
call = calls[0]
assert call.domain == 'homeassistant'
assert call.domain == HASS_DOMAIN
assert call.service == 'turn_on'
assert call.data == {'entity_id': 'light.kitchen'}