Rename MockToggleDevice to MockToggleEntity (#26644)

* Rename MockToggleDevice to MockToggleEntity

* Fix tests
This commit is contained in:
Erik Montnemery 2019-09-15 09:50:17 +02:00 committed by GitHub
parent 57833f5b1e
commit 6a60ebdb30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 200 additions and 198 deletions

View file

@ -602,40 +602,40 @@ class MockEntityPlatform(entity_platform.EntityPlatform):
)
class MockToggleDevice(entity.ToggleEntity):
class MockToggleEntity(entity.ToggleEntity):
"""Provide a mock toggle device."""
def __init__(self, name, state):
"""Initialize the mock device."""
def __init__(self, name, state, unique_id=None):
"""Initialize the mock entity."""
self._name = name or DEVICE_DEFAULT_NAME
self._state = state
self.calls = []
@property
def name(self):
"""Return the name of the device if any."""
"""Return the name of the entity if any."""
self.calls.append(("name", {}))
return self._name
@property
def state(self):
"""Return the name of the device if any."""
"""Return the state of the entity if any."""
self.calls.append(("state", {}))
return self._state
@property
def is_on(self):
"""Return true if device is on."""
"""Return true if entity is on."""
self.calls.append(("is_on", {}))
return self._state == STATE_ON
def turn_on(self, **kwargs):
"""Turn the device on."""
"""Turn the entity on."""
self.calls.append(("turn_on", kwargs))
self._state = STATE_ON
def turn_off(self, **kwargs):
"""Turn the device off."""
"""Turn the entity off."""
self.calls.append(("turn_off", kwargs))
self._state = STATE_OFF