Skip to content

Commit 13e9641

Browse files
committed
Added some simple tests
1 parent 0c68837 commit 13e9641

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

custom_components/pyscript/webhook.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def notify_add(cls, webhook_id, local_only, methods, queue):
5959
_LOGGER.debug("webhook.notify_add(%s) -> adding webhook listener", webhook_id)
6060
webhook.async_register(
6161
cls.hass,
62-
"webhook", # DOMAIN - unclear what this is used for
63-
"pyscript", # NAME - unclear what this is used for
62+
"pyscript", # DOMAIN
63+
"pyscript", # NAME
6464
webhook_id,
6565
cls.webhook_handler,
6666
local_only=local_only,

tests/test_decorator_errors.py

+20
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,23 @@ def func7():
461461
"TypeError: function 'func7' defined in file.hello: decorator @state_trigger keyword 'watch' should be type list or set"
462462
in caplog.text
463463
)
464+
465+
466+
@pytest.mark.asyncio
467+
async def test_webhooks_method(hass, caplog):
468+
"""Test invalid keyword arguments type generates an error."""
469+
470+
await setup_script(
471+
hass,
472+
None,
473+
dt(2020, 7, 1, 11, 59, 59, 999999),
474+
"""
475+
@webhook_trigger("hook", methods=["bad"])
476+
def func8():
477+
pass
478+
""",
479+
)
480+
assert (
481+
"TypeError: function 'func8' defined in file.hello: {'bad'} aren't valid webhook_trigger methods"
482+
in caplog.text
483+
)

tests/test_jupyter.py

+2
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ async def test_jupyter_kernel_redefine_func(hass, caplog, socket_enabled):
487487
@time_trigger("once(2019/9/7 12:00)")
488488
@state_trigger("pyscript.var1 == '1'")
489489
@event_trigger("test_event")
490+
@webhook_trigger("test_hook1")
490491
def func():
491492
pass
492493
123
@@ -504,6 +505,7 @@ def func():
504505
@time_trigger("once(2019/9/7 13:00)")
505506
@state_trigger("pyscript.var1 == '1'")
506507
@event_trigger("test_event2")
508+
@webhook_trigger("test_hook1")
507509
def func():
508510
pass
509511
321

0 commit comments

Comments
 (0)