Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
KapJI committed May 17, 2021
1 parent 6b4ef6d commit 9180ba0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,29 @@ async def wait_finish_callback():
assert len(call_count) == 2


async def test_async_create_task_pending_tasks_coro(hass):
"""Add a coro to pending tasks."""
call_count = []

async def test_coro():
"""Test Coro."""
call_count.append("call")

for _ in range(2):
hass.create_task(test_coro())

async def wait_finish_callback():
"""Wait until all stuff is scheduled."""
await asyncio.sleep(0)
await asyncio.sleep(0)

await wait_finish_callback()

assert len(hass._pending_tasks) == 2
await hass.async_block_till_done()
assert len(call_count) == 2


async def test_async_add_job_pending_tasks_executor(hass):
"""Run an executor in pending tasks."""
call_count = []
Expand Down

0 comments on commit 9180ba0

Please sign in to comment.