1
1
"""The tests for the Google Assistant component."""
2
2
3
- from asyncio import AbstractEventLoop
4
3
from http import HTTPStatus
5
4
import json
6
5
from unittest .mock import patch
@@ -38,32 +37,28 @@ def auth_header(hass_access_token: str) -> dict[str, str]:
38
37
39
38
40
39
@pytest .fixture
41
- def assistant_client (
42
- event_loop : AbstractEventLoop ,
40
+ async def assistant_client (
43
41
hass : core .HomeAssistant ,
44
42
hass_client_no_auth : ClientSessionGenerator ,
45
43
) -> TestClient :
46
44
"""Create web client for the Google Assistant API."""
47
- loop = event_loop
48
- loop .run_until_complete (
49
- setup .async_setup_component (
50
- hass ,
51
- "google_assistant" ,
52
- {
53
- "google_assistant" : {
54
- "project_id" : PROJECT_ID ,
55
- "entity_config" : {
56
- "light.ceiling_lights" : {
57
- "aliases" : ["top lights" , "ceiling lights" ],
58
- "name" : "Roof Lights" ,
59
- }
60
- },
61
- }
62
- },
63
- )
45
+ await setup .async_setup_component (
46
+ hass ,
47
+ "google_assistant" ,
48
+ {
49
+ "google_assistant" : {
50
+ "project_id" : PROJECT_ID ,
51
+ "entity_config" : {
52
+ "light.ceiling_lights" : {
53
+ "aliases" : ["top lights" , "ceiling lights" ],
54
+ "name" : "Roof Lights" ,
55
+ }
56
+ },
57
+ }
58
+ },
64
59
)
65
60
66
- return loop . run_until_complete ( hass_client_no_auth () )
61
+ return await hass_client_no_auth ()
67
62
68
63
69
64
@pytest .fixture (autouse = True )
@@ -87,16 +82,12 @@ async def wanted_platforms_only() -> None:
87
82
88
83
89
84
@pytest .fixture
90
- def hass_fixture (
91
- event_loop : AbstractEventLoop , hass : core .HomeAssistant
92
- ) -> core .HomeAssistant :
85
+ async def hass_fixture (hass : core .HomeAssistant ) -> core .HomeAssistant :
93
86
"""Set up a Home Assistant instance for these tests."""
94
- loop = event_loop
95
-
96
87
# We need to do this to get access to homeassistant/turn_(on,off)
97
- loop . run_until_complete ( setup .async_setup_component (hass , core .DOMAIN , {}) )
88
+ await setup .async_setup_component (hass , core .DOMAIN , {})
98
89
99
- loop . run_until_complete ( setup .async_setup_component (hass , "demo" , {}) )
90
+ await setup .async_setup_component (hass , "demo" , {})
100
91
101
92
return hass
102
93
0 commit comments