allow extra slot values in intents (#15246)
This commit is contained in:
1 parent
4c258ce08b
commit
136cc1d44d
3 files changed
+81
-2
No files matched your search
@@ -1,6 +1,18 @@
|
||||
"""Tests for the intent helpers."""
|
||||
|
||||
import unittest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers import intent
|
||||
from homeassistant.helpers import (intent, config_validation as cv)
|
||||
|
||||
|
||||
class MockIntentHandler(intent.IntentHandler):
|
||||
"""Provide a mock intent handler."""
|
||||
|
||||
def __init__(self, slot_schema):
|
||||
"""Initialize the mock handler."""
|
||||
self.slot_schema = slot_schema
|
||||
|
||||
|
||||
def test_async_match_state():
|
||||
@@ -10,3 +22,25 @@ def test_async_match_state():
|
||||
|
||||
state = intent.async_match_state(None, 'kitch', [state1, state2])
|
||||
assert state is state1
|
||||
|
||||
|
||||
class TestIntentHandler(unittest.TestCase):
|
||||
"""Test the Home Assistant event helpers."""
|
||||
|
||||
def test_async_validate_slots(self):
|
||||
"""Test async_validate_slots of IntentHandler."""
|
||||
handler1 = MockIntentHandler({
|
||||
vol.Required('name'): cv.string,
|
||||
})
|
||||
|
||||
self.assertRaises(vol.error.MultipleInvalid,
|
||||
handler1.async_validate_slots, {})
|
||||
self.assertRaises(vol.error.MultipleInvalid,
|
||||
handler1.async_validate_slots, {'name': 1})
|
||||
self.assertRaises(vol.error.MultipleInvalid,
|
||||
handler1.async_validate_slots, {'name': 'kitchen'})
|
||||
handler1.async_validate_slots({'name': {'value': 'kitchen'}})
|
||||
handler1.async_validate_slots({
|
||||
'name': {'value': 'kitchen'},
|
||||
'probability': {'value': '0.5'}
|
||||
})
|
||||
Reference in new issue
Block a user