1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add Hyperion device support (#47881)

* Add Hyperion device support.

* Update to the new typing annotations.

* Add device cleanup logic.

* Fixes based on the excellent feedback from emontnemery
This commit is contained in:
Dermot Duffy
2021-04-13 01:35:38 -07:00
committed by GitHub
parent 5bf3469ffc
commit 63d42867e8
8 changed files with 389 additions and 129 deletions

View File

@@ -2,7 +2,7 @@
from __future__ import annotations
import asyncio
from typing import Any
from typing import Any, Awaitable
from unittest.mock import AsyncMock, Mock, patch
from hyperion import const
@@ -419,13 +419,13 @@ async def test_auth_create_token_approval_declined_task_canceled(
class CanceledAwaitableMock(AsyncMock):
"""A canceled awaitable mock."""
def __await__(self):
def __await__(self) -> None:
raise asyncio.CancelledError
mock_task = CanceledAwaitableMock()
task_coro = None
task_coro: Awaitable | None = None
def create_task(arg):
def create_task(arg: Any) -> CanceledAwaitableMock:
nonlocal task_coro
task_coro = arg
return mock_task
@@ -453,6 +453,7 @@ async def test_auth_create_token_approval_declined_task_canceled(
result = await _configure_flow(hass, result)
# This await will advance to the next step.
assert task_coro
await task_coro
# Assert that cancel is called on the task.