Configure conversation for custom actions with keywords (#7734)
* - Simple keyword to action config * - Added more fuzzy stuff * - Logging & a bit of commenting * - pep8? * - pep8 and quick formatting fixes * - Changed configuration a bit * - Backwards compatibility tests * - Fallback or * - Added custom configuration for conversation * - Moved imports inside function * - pep8 * - Pass tests better * - Removed unused imports * - Moved warning ignore to above import for fuzzy * - Moved return for consistent return types * - Fallback if no choices to listen for * - Fixed linting errors * - Better logging and fixed linting errors(?) * - Fixed continuation * - Added one blank line after class docstring * Create conversation.py * Create test_conversation.py * Create test_conversation.py * Update test_conversation.py
This commit is contained in:
1 parent
843f8ce9ee
commit
7fae8cd0f1
2 files changed
+73
-4
No files matched your search
@@ -117,3 +117,46 @@ class TestConversation(unittest.TestCase):
|
||||
conversation.DOMAIN, 'process', event_data, True))
|
||||
self.assertTrue(mock_logger.called)
|
||||
self.assertFalse(mock_call.called)
|
||||
|
||||
|
||||
class TestConfiguration(unittest.TestCase):
|
||||
"""Test the conversation configuration component."""
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def setUp(self):
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.assertTrue(setup_component(self.hass, conversation.DOMAIN, {
|
||||
conversation.DOMAIN: {
|
||||
'test_2': {
|
||||
'sentence': 'switch boolean',
|
||||
'action': {
|
||||
'service': 'input_boolean.toggle'
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_custom(self):
|
||||
"""Setup and perform good turn on requests."""
|
||||
calls = []
|
||||
|
||||
@callback
|
||||
def record_call(service):
|
||||
"""Recorder for a call."""
|
||||
calls.append(service)
|
||||
|
||||
self.hass.services.register('input_boolean', 'toggle', record_call)
|
||||
|
||||
event_data = {conversation.ATTR_TEXT: 'switch boolean'}
|
||||
self.assertTrue(self.hass.services.call(
|
||||
conversation.DOMAIN, 'process', event_data, True))
|
||||
|
||||
call = calls[-1]
|
||||
self.assertEqual('input_boolean', call.domain)
|
||||
self.assertEqual('toggle', call.service)
|
||||
Reference in new issue
Block a user