Clean up entity component (#11691)

* Clean up entity component

* Lint

* List -> Tuple

* Add Entity.async_remove back

* Unflake setting up group test
This commit is contained in:
Paulus Schoutsen 2018-01-22 22:54:41 -08:00 committed by GitHub
parent d478517c51
commit 183e0543b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 230 additions and 191 deletions

View file

@ -86,6 +86,7 @@ class TestHelpersEntityComponent(unittest.TestCase):
assert len(self.hass.states.entity_ids()) == 0
component.add_entities([EntityTest()])
self.hass.block_till_done()
# group exists
assert len(self.hass.states.entity_ids()) == 2
@ -98,6 +99,7 @@ class TestHelpersEntityComponent(unittest.TestCase):
# group extended
component.add_entities([EntityTest(name='goodbye')])
self.hass.block_till_done()
assert len(self.hass.states.entity_ids()) == 3
group = self.hass.states.get('group.everyone')
@ -214,7 +216,7 @@ class TestHelpersEntityComponent(unittest.TestCase):
assert 0 == len(self.hass.states.entity_ids())
component.add_entities([None, EntityTest(unique_id='not_very_unique')])
component.add_entities([EntityTest(unique_id='not_very_unique')])
assert 1 == len(self.hass.states.entity_ids())
@ -671,3 +673,14 @@ def test_raise_error_on_update(hass):
assert len(updates) == 1
assert 1 in updates
@asyncio.coroutine
def test_async_remove_with_platform(hass):
"""Remove an entity from a platform."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
entity1 = EntityTest(name='test_1')
yield from component.async_add_entities([entity1])
assert len(hass.states.async_entity_ids()) == 1
yield from entity1.async_remove()
assert len(hass.states.async_entity_ids()) == 0