Add Intent component (#8434)
* Add intent component * Add intent script component * Add shopping list component * Convert Snips to use intent component * Convert Alexa to use intent component * Lint * Fix Alexa tests * Update snips test * Add intent support to conversation * Add API to view shopping list contents * Lint * Fix demo test * Lint * lint * Remove type from slot schema * Add dependency to conversation * Move intent to be a helper * Fix conversation * Clean up intent helper * Fix Alexa * Snips to use new hass.components * Allow registering intents with conversation at any point in time * Shopping list to register sentences * Add HTTP endpoint to Conversation * Add async action option to intent_script * Update API.ai to use intents * Cleanup Alexa * Shopping list component to register built-in panel * Rename shopping list intent to inlude Hass name
This commit is contained in:
parent
7bea69ce83
commit
7edf14e55f
16 changed files with 970 additions and 396 deletions
|
@ -1,52 +1,62 @@
|
|||
"""The tests for the Demo component."""
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from homeassistant.setup import setup_component
|
||||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components import demo, device_tracker
|
||||
from homeassistant.remote import JSONEncoder
|
||||
|
||||
from tests.common import mock_http_component, get_test_home_assistant
|
||||
|
||||
@pytest.fixture
|
||||
def minimize_demo_platforms(hass):
|
||||
"""Cleanup demo component for tests."""
|
||||
orig = demo.COMPONENTS_WITH_DEMO_PLATFORM
|
||||
demo.COMPONENTS_WITH_DEMO_PLATFORM = [
|
||||
'switch', 'light', 'media_player']
|
||||
|
||||
yield
|
||||
|
||||
demo.COMPONENTS_WITH_DEMO_PLATFORM = orig
|
||||
|
||||
|
||||
class TestDemo(unittest.TestCase):
|
||||
"""Test the Demo component."""
|
||||
@pytest.fixture(autouse=True)
|
||||
def demo_cleanup(hass):
|
||||
"""Clean up device tracker demo file."""
|
||||
yield
|
||||
try:
|
||||
os.remove(hass.config.path(device_tracker.YAML_DEVICES))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
mock_http_component(self.hass)
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
@asyncio.coroutine
|
||||
def test_if_demo_state_shows_by_default(hass, minimize_demo_platforms):
|
||||
"""Test if demo state shows if we give no configuration."""
|
||||
yield from async_setup_component(hass, demo.DOMAIN, {demo.DOMAIN: {}})
|
||||
|
||||
try:
|
||||
os.remove(self.hass.config.path(device_tracker.YAML_DEVICES))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
assert hass.states.get('a.Demo_Mode') is not None
|
||||
|
||||
def test_if_demo_state_shows_by_default(self):
|
||||
"""Test if demo state shows if we give no configuration."""
|
||||
setup_component(self.hass, demo.DOMAIN, {demo.DOMAIN: {}})
|
||||
|
||||
self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))
|
||||
@asyncio.coroutine
|
||||
def test_hiding_demo_state(hass, minimize_demo_platforms):
|
||||
"""Test if you can hide the demo card."""
|
||||
yield from async_setup_component(hass, demo.DOMAIN, {
|
||||
demo.DOMAIN: {'hide_demo_state': 1}})
|
||||
|
||||
def test_hiding_demo_state(self):
|
||||
"""Test if you can hide the demo card."""
|
||||
setup_component(self.hass, demo.DOMAIN, {
|
||||
demo.DOMAIN: {'hide_demo_state': 1}})
|
||||
assert hass.states.get('a.Demo_Mode') is None
|
||||
|
||||
self.assertIsNone(self.hass.states.get('a.Demo_Mode'))
|
||||
|
||||
def test_all_entities_can_be_loaded_over_json(self):
|
||||
"""Test if you can hide the demo card."""
|
||||
setup_component(self.hass, demo.DOMAIN, {
|
||||
demo.DOMAIN: {'hide_demo_state': 1}})
|
||||
@asyncio.coroutine
|
||||
def test_all_entities_can_be_loaded_over_json(hass):
|
||||
"""Test if you can hide the demo card."""
|
||||
yield from async_setup_component(hass, demo.DOMAIN, {
|
||||
demo.DOMAIN: {'hide_demo_state': 1}})
|
||||
|
||||
try:
|
||||
json.dumps(self.hass.states.all(), cls=JSONEncoder)
|
||||
except Exception:
|
||||
self.fail('Unable to convert all demo entities to JSON. '
|
||||
'Wrong data in state machine!')
|
||||
try:
|
||||
json.dumps(hass.states.async_all(), cls=JSONEncoder)
|
||||
except Exception:
|
||||
pytest.fail('Unable to convert all demo entities to JSON. '
|
||||
'Wrong data in state machine!')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue