Update nest library and switch events to async (#43583)

This commit is contained in:
Allen Porter 2020-11-24 07:53:50 -08:00 committed by GitHub
parent 7214d6517a
commit 3dd14e05e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 16 deletions

View file

@ -417,7 +417,7 @@ async def test_thermostat_set_hvac_mode(hass, auth):
},
auth=None,
)
subscriber.receive_event(event)
await subscriber.async_receive_event(event)
await hass.async_block_till_done() # Process dispatch/update signal
thermostat = hass.states.get("climate.my_thermostat")
@ -441,7 +441,7 @@ async def test_thermostat_set_hvac_mode(hass, auth):
},
auth=None,
)
subscriber.receive_event(event)
await subscriber.async_receive_event(event)
await hass.async_block_till_done() # Process dispatch/update signal
thermostat = hass.states.get("climate.my_thermostat")
@ -514,7 +514,7 @@ async def test_thermostat_set_eco_preset(hass, auth):
},
auth=auth,
)
subscriber.receive_event(event)
await subscriber.async_receive_event(event)
await hass.async_block_till_done() # Process dispatch/update signal
thermostat = hass.states.get("climate.my_thermostat")
@ -834,7 +834,7 @@ async def test_thermostat_target_temp(hass, auth):
},
auth=None,
)
subscriber.receive_event(event)
await subscriber.async_receive_event(event)
await hass.async_block_till_done() # Process dispatch/update signal
thermostat = hass.states.get("climate.my_thermostat")

View file

@ -3,7 +3,7 @@
import time
from google_nest_sdm.device_manager import DeviceManager
from google_nest_sdm.event import EventCallback, EventMessage
from google_nest_sdm.event import AsyncEventCallback, EventMessage
from google_nest_sdm.google_nest_subscriber import GoogleNestSubscriber
from homeassistant.components.nest import DOMAIN
@ -61,7 +61,7 @@ class FakeSubscriber(GoogleNestSubscriber):
self._device_manager = device_manager
self._callback = None
def set_update_callback(self, callback: EventCallback):
def set_update_callback(self, callback: AsyncEventCallback):
"""Capture the callback set by Home Assistant."""
self._callback = callback
@ -77,11 +77,11 @@ class FakeSubscriber(GoogleNestSubscriber):
"""No-op to stop the subscriber."""
return None
def receive_event(self, event_message: EventMessage):
async def async_receive_event(self, event_message: EventMessage):
"""Simulate a received pubsub message, invoked by tests."""
# Update device state, then invoke HomeAssistant to refresh
self._device_manager.handle_event(event_message)
self._callback.handle_event(event_message)
await self._device_manager.async_handle_event(event_message)
await self._callback.async_handle_event(event_message)
async def async_setup_sdm_platform(hass, platform, devices={}, structures={}):

View file

@ -164,7 +164,7 @@ async def test_event_updates_sensor(hass):
},
auth=None,
)
subscriber.receive_event(event)
await subscriber.async_receive_event(event)
await hass.async_block_till_done() # Process dispatch/update signal
temperature = hass.states.get("sensor.my_sensor_temperature")