mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Black
This commit is contained in:
@@ -5,7 +5,7 @@ import voluptuous as vol
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers import (intent, config_validation as cv)
|
||||
from homeassistant.helpers import intent, config_validation as cv
|
||||
|
||||
|
||||
class MockIntentHandler(intent.IntentHandler):
|
||||
@@ -18,27 +18,24 @@ class MockIntentHandler(intent.IntentHandler):
|
||||
|
||||
def test_async_match_state():
|
||||
"""Test async_match_state helper."""
|
||||
state1 = State('light.kitchen', 'on')
|
||||
state2 = State('switch.kitchen', 'on')
|
||||
state1 = State("light.kitchen", "on")
|
||||
state2 = State("switch.kitchen", "on")
|
||||
|
||||
state = intent.async_match_state(None, 'kitch', [state1, state2])
|
||||
state = intent.async_match_state(None, "kitch", [state1, state2])
|
||||
assert state is state1
|
||||
|
||||
|
||||
def test_async_validate_slots():
|
||||
"""Test async_validate_slots of IntentHandler."""
|
||||
handler1 = MockIntentHandler({
|
||||
vol.Required('name'): cv.string,
|
||||
})
|
||||
handler1 = MockIntentHandler({vol.Required("name"): cv.string})
|
||||
|
||||
with pytest.raises(vol.error.MultipleInvalid):
|
||||
handler1.async_validate_slots({})
|
||||
with pytest.raises(vol.error.MultipleInvalid):
|
||||
handler1.async_validate_slots({'name': 1})
|
||||
handler1.async_validate_slots({"name": 1})
|
||||
with pytest.raises(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'}
|
||||
})
|
||||
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