|
3 | 3 | from ast import literal_eval
|
4 | 4 | import asyncio
|
5 | 5 | from datetime import datetime as dt
|
6 |
| -import time |
7 | 6 |
|
8 | 7 | from custom_components.pyscript.const import CONF_ALLOW_ALL_IMPORTS, CONF_HASS_IS_GLOBAL, DOMAIN
|
9 | 8 | from custom_components.pyscript.function import Function
|
@@ -259,7 +258,7 @@ def func4(trigger_type=None, event_type=None, **kwargs):
|
259 | 258 | global seq_num
|
260 | 259 |
|
261 | 260 | seq_num += 1
|
262 |
| - res = task.wait_until(event_trigger=["test_event4b", "arg1 == 25 and arg2 == 35"], timeout=10) |
| 261 | + res = task.wait_until(event_trigger=["test_event4b", "arg1 == 25 and arg2 == 35"], timeout=10, __test_handshake__=["pyscript.done2", seq_num]) |
263 | 262 | log.info(f"func4 trigger_type = {res}, event_type = {event_type}, event_data = {kwargs}")
|
264 | 263 | kwargs["context"] = {"user_id": kwargs["context"].user_id, "parent_id": kwargs["context"].parent_id, "id": "1234"}
|
265 | 264 | res["context"] = kwargs["context"]
|
@@ -599,12 +598,10 @@ def func9(var_name=None, value=None, old_value=None):
|
599 | 598 | seq_num += 1
|
600 | 599 | hass.states.async_set("pyscript.f4var2", 2)
|
601 | 600 | hass.bus.async_fire("test_event4", {"arg1": 20, "arg2": 30})
|
602 |
| - t_now = time.monotonic() |
603 |
| - while notify_q.empty() and time.monotonic() < t_now + 4: |
604 |
| - hass.bus.async_fire("test_event4b", {"arg1": 15, "arg2": 25}) |
605 |
| - hass.bus.async_fire("test_event4b", {"arg1": 20, "arg2": 25}) |
606 |
| - hass.bus.async_fire("test_event4b", {"arg1": 25, "arg2": 35}) |
607 |
| - await asyncio.sleep(2e-3) |
| 601 | + assert literal_eval(await wait_until_done(notify_q2)) == seq_num |
| 602 | + hass.bus.async_fire("test_event4b", {"arg1": 20, "arg2": 25}) |
| 603 | + hass.bus.async_fire("test_event4b", {"arg1": 15, "arg2": 25}) |
| 604 | + hass.bus.async_fire("test_event4b", {"arg1": 25, "arg2": 35}) |
608 | 605 | trig = {
|
609 | 606 | "trigger_type": "event",
|
610 | 607 | "event_type": "test_event4b",
|
|
0 commit comments