Replace executor with async_add_job (#7658)
* Remove executor * Lint * Lint * Fix tests
This commit is contained in:
parent
9e9705d6b2
commit
f43db3c615
46 changed files with 196 additions and 248 deletions
|
@ -31,26 +31,21 @@ def test_generate_entity_id_given_keys():
|
|||
'test.another_entity']) == 'test.overwrite_hidden_true'
|
||||
|
||||
|
||||
def test_async_update_support(event_loop):
|
||||
def test_async_update_support(hass):
|
||||
"""Test async update getting called."""
|
||||
sync_update = []
|
||||
async_update = []
|
||||
|
||||
class AsyncEntity(entity.Entity):
|
||||
hass = MagicMock()
|
||||
entity_id = 'sensor.test'
|
||||
|
||||
def update(self):
|
||||
sync_update.append([1])
|
||||
|
||||
ent = AsyncEntity()
|
||||
ent.hass.loop = event_loop
|
||||
ent.hass = hass
|
||||
|
||||
@asyncio.coroutine
|
||||
def test():
|
||||
yield from ent.async_update_ha_state(True)
|
||||
|
||||
event_loop.run_until_complete(test())
|
||||
hass.loop.run_until_complete(ent.async_update_ha_state(True))
|
||||
|
||||
assert len(sync_update) == 1
|
||||
assert len(async_update) == 0
|
||||
|
@ -62,7 +57,7 @@ def test_async_update_support(event_loop):
|
|||
|
||||
ent.async_update = async_update_func
|
||||
|
||||
event_loop.run_until_complete(test())
|
||||
hass.loop.run_until_complete(ent.async_update_ha_state(True))
|
||||
|
||||
assert len(sync_update) == 1
|
||||
assert len(async_update) == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue