Add mode info attributes to script and automation (#37815)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
ac0dbb17af
commit
7d77fa92c2
8 changed files with 53 additions and 80 deletions
|
@ -93,15 +93,12 @@ async def test_firing_event_basic(hass):
|
|||
sequence = cv.SCRIPT_SCHEMA({"event": event, "event_data": {"hello": "world"}})
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
await script_obj.async_run(context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(events) == 1
|
||||
assert events[0].context is context
|
||||
assert events[0].data.get("hello") == "world"
|
||||
assert script_obj.can_cancel
|
||||
|
||||
|
||||
async def test_firing_event_template(hass):
|
||||
|
@ -125,8 +122,6 @@ async def test_firing_event_template(hass):
|
|||
)
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
await script_obj.async_run({"is_world": "yes"}, context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -146,8 +141,6 @@ async def test_calling_service_basic(hass):
|
|||
sequence = cv.SCRIPT_SCHEMA({"service": "test.script", "data": {"hello": "world"}})
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
await script_obj.async_run(context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -182,8 +175,6 @@ async def test_calling_service_template(hass):
|
|||
)
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
await script_obj.async_run({"is_world": "yes"}, context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -267,8 +258,6 @@ async def test_activating_scene(hass):
|
|||
sequence = cv.SCRIPT_SCHEMA({"scene": "scene.hello"})
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
await script_obj.async_run(context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -328,8 +317,6 @@ async def test_delay_basic(hass, mock_timeout):
|
|||
script_obj = script.Script(hass, sequence)
|
||||
delay_started_flag = async_watch_for_action(script_obj, delay_alias)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
try:
|
||||
hass.async_create_task(script_obj.async_run())
|
||||
await asyncio.wait_for(delay_started_flag.wait(), 1)
|
||||
|
@ -394,8 +381,6 @@ async def test_delay_template_ok(hass, mock_timeout):
|
|||
script_obj = script.Script(hass, sequence)
|
||||
delay_started_flag = async_watch_for_action(script_obj, "delay")
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
try:
|
||||
hass.async_create_task(script_obj.async_run())
|
||||
await asyncio.wait_for(delay_started_flag.wait(), 1)
|
||||
|
@ -444,8 +429,6 @@ async def test_delay_template_complex_ok(hass, mock_timeout):
|
|||
script_obj = script.Script(hass, sequence)
|
||||
delay_started_flag = async_watch_for_action(script_obj, "delay")
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
try:
|
||||
hass.async_create_task(script_obj.async_run())
|
||||
await asyncio.wait_for(delay_started_flag.wait(), 1)
|
||||
|
@ -530,8 +513,6 @@ async def test_wait_template_basic(hass):
|
|||
script_obj = script.Script(hass, sequence)
|
||||
wait_started_flag = async_watch_for_action(script_obj, wait_alias)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
try:
|
||||
hass.states.async_set("switch.test", "on")
|
||||
hass.async_create_task(script_obj.async_run())
|
||||
|
@ -687,8 +668,6 @@ async def test_wait_template_variables(hass):
|
|||
script_obj = script.Script(hass, sequence)
|
||||
wait_started_flag = async_watch_for_action(script_obj, "wait")
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
try:
|
||||
hass.states.async_set("switch.test", "on")
|
||||
hass.async_create_task(script_obj.async_run({"data": "switch.test"}))
|
||||
|
@ -721,8 +700,6 @@ async def test_condition_basic(hass):
|
|||
)
|
||||
script_obj = script.Script(hass, sequence)
|
||||
|
||||
assert script_obj.can_cancel
|
||||
|
||||
hass.states.async_set("test.entity", "hello")
|
||||
await script_obj.async_run()
|
||||
await hass.async_block_till_done()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue