mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Convert alexa test fixtures to async (#142054)
This commit is contained in:
parent
6b45b0f522
commit
e02a6f2f19
@ -1,6 +1,5 @@
|
||||
"""The tests for the Alexa component."""
|
||||
|
||||
from asyncio import AbstractEventLoop
|
||||
import datetime
|
||||
from http import HTTPStatus
|
||||
|
||||
@ -24,13 +23,11 @@ NPR_NEWS_MP3_URL = "https://pd.npr.org/anon.npr-mp3/npr/news/newscast.mp3"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alexa_client(
|
||||
event_loop: AbstractEventLoop,
|
||||
async def alexa_client(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
) -> TestClient:
|
||||
"""Initialize a Home Assistant server for testing this module."""
|
||||
loop = event_loop
|
||||
|
||||
@callback
|
||||
def mock_service(call):
|
||||
@ -38,8 +35,7 @@ def alexa_client(
|
||||
|
||||
hass.services.async_register("test", "alexa", mock_service)
|
||||
|
||||
assert loop.run_until_complete(
|
||||
async_setup_component(
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
alexa.DOMAIN,
|
||||
{
|
||||
@ -68,8 +64,7 @@ def alexa_client(
|
||||
},
|
||||
},
|
||||
)
|
||||
)
|
||||
return loop.run_until_complete(hass_client())
|
||||
return await hass_client()
|
||||
|
||||
|
||||
def _flash_briefing_req(client, briefing_id, password="pass%2Fabc"):
|
||||
|
@ -1,6 +1,5 @@
|
||||
"""The tests for the Alexa component."""
|
||||
|
||||
from asyncio import AbstractEventLoop
|
||||
from http import HTTPStatus
|
||||
import json
|
||||
|
||||
@ -30,13 +29,11 @@ NPR_NEWS_MP3_URL = "https://pd.npr.org/anon.npr-mp3/npr/news/newscast.mp3"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alexa_client(
|
||||
event_loop: AbstractEventLoop,
|
||||
async def alexa_client(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
) -> TestClient:
|
||||
"""Initialize a Home Assistant server for testing this module."""
|
||||
loop = event_loop
|
||||
|
||||
@callback
|
||||
def mock_service(call):
|
||||
@ -44,8 +41,7 @@ def alexa_client(
|
||||
|
||||
hass.services.async_register("test", "alexa", mock_service)
|
||||
|
||||
assert loop.run_until_complete(
|
||||
async_setup_component(
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
alexa.DOMAIN,
|
||||
{
|
||||
@ -54,9 +50,7 @@ def alexa_client(
|
||||
"alexa": {},
|
||||
},
|
||||
)
|
||||
)
|
||||
assert loop.run_until_complete(
|
||||
async_setup_component(
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
"intent_script",
|
||||
{
|
||||
@ -132,8 +126,7 @@ def alexa_client(
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
return loop.run_until_complete(hass_client())
|
||||
return await hass_client()
|
||||
|
||||
|
||||
def _intent_req(client, data=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user