|
5 | 5 | import pathlib |
6 | 6 |
|
7 | 7 | from custom_components.pyscript.const import DOMAIN |
| 8 | +from custom_components.pyscript.event import Event |
| 9 | +from custom_components.pyscript.function import Function |
| 10 | +from custom_components.pyscript.global_ctx import GlobalContextMgr |
| 11 | +from custom_components.pyscript.state import State |
8 | 12 | import custom_components.pyscript.trigger as trigger |
9 | 13 | from pytest_homeassistant.async_mock import mock_open, patch |
10 | 14 |
|
@@ -285,7 +289,11 @@ def func2(**kwargs): |
285 | 289 |
|
286 | 290 | @service |
287 | 291 | def call_service(domain=None, name=None, **kwargs): |
288 | | - service.call(domain, name, **kwargs) |
| 292 | + if domain == "pyscript" and name == "func1": |
| 293 | + task.sleep(0) |
| 294 | + pyscript.func1(**kwargs) |
| 295 | + else: |
| 296 | + service.call(domain, name, **kwargs) |
289 | 297 |
|
290 | 298 | """, |
291 | 299 | ) |
@@ -447,3 +455,22 @@ def func5(var_name=None, value=None): |
447 | 455 | "custom_components.pyscript.trigger.dt_now", return_value=now |
448 | 456 | ): |
449 | 457 | await hass.services.async_call("pyscript", "reload", {}, blocking=True) |
| 458 | + |
| 459 | + |
| 460 | +async def test_misc_errors(hass, caplog): |
| 461 | + """Test miscellaneous errors.""" |
| 462 | + |
| 463 | + await setup_script(hass, None, dt(2020, 7, 1, 11, 59, 59, 999999), "") |
| 464 | + |
| 465 | + Function() |
| 466 | + GlobalContextMgr() |
| 467 | + State() |
| 468 | + Event() |
| 469 | + Event.notify_del("not_in_notify_list", None) |
| 470 | + trigger.TrigTime() |
| 471 | + |
| 472 | + assert "Function class is not meant to be instantiated" in caplog.text |
| 473 | + assert "GlobalContextMgr class is not meant to be instantiated" in caplog.text |
| 474 | + assert "State class is not meant to be instantiated" in caplog.text |
| 475 | + assert "Event class is not meant to be instantiated" in caplog.text |
| 476 | + assert "TrigTime class is not meant to be instantiated" in caplog.text |
0 commit comments