Removed property from universal media player

The active_child_state property was unnecessary as it was not being
referenced outside the class. This commit removes it and updates the
tests accordingly.
This commit is contained in:
Ryan Kraus 2016-01-12 20:45:53 -05:00 committed by Paulus Schoutsen
parent 769f5aafb7
commit 12da6f531e
2 changed files with 8 additions and 13 deletions

View File

@ -171,7 +171,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
def _child_attr(self, attr_name): def _child_attr(self, attr_name):
""" returns the active child's attr """ """ returns the active child's attr """
active_child = self.active_child_state active_child = self._child_state
return active_child.attributes.get(attr_name) if active_child else None return active_child.attributes.get(attr_name) if active_child else None
def _call_service(self, service_name, service_data=None, def _call_service(self, service_name, service_data=None,
@ -185,7 +185,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
if service_data is None: if service_data is None:
service_data = {} service_data = {}
active_child = self.active_child_state active_child = self._child_state
service_data[ATTR_ENTITY_ID] = active_child.entity_id service_data[ATTR_ENTITY_ID] = active_child.entity_id
self.hass.services.call(DOMAIN, service_name, service_data, self.hass.services.call(DOMAIN, service_name, service_data,
@ -222,11 +222,6 @@ class UniversalMediaPlayer(MediaPlayerDevice):
return return
self._child_state = None self._child_state = None
@property
def active_child_state(self):
""" the state of the active child or none """
return self._child_state
@property @property
def name(self): def name(self):
""" name of universal player """ """ name of universal player """
@ -245,7 +240,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
if master_state == STATE_OFF: if master_state == STATE_OFF:
return STATE_OFF return STATE_OFF
active_child = self.active_child_state active_child = self._child_state
if active_child: if active_child:
return active_child.state return active_child.state
@ -366,7 +361,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
""" Extra attributes a device wants to expose. """ """ Extra attributes a device wants to expose. """
active_child = self.active_child_state active_child = self._child_state
return {ATTR_ACTIVE_CHILD: active_child.entity_id} \ return {ATTR_ACTIVE_CHILD: active_child.entity_id} \
if active_child else {} if active_child else {}

View File

@ -193,25 +193,25 @@ class TestMediaPlayer(unittest.TestCase):
ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config['name']) ump.entity_id = media_player.ENTITY_ID_FORMAT.format(config['name'])
ump.update_state() ump.update_state()
self.assertEqual(None, ump.active_child_state) self.assertEqual(None, ump._child_state)
self.mock_mp_1._state = STATE_PLAYING self.mock_mp_1._state = STATE_PLAYING
self.mock_mp_1.update_ha_state() self.mock_mp_1.update_ha_state()
ump.update_state() ump.update_state()
self.assertEqual(self.mock_mp_1.entity_id, self.assertEqual(self.mock_mp_1.entity_id,
ump.active_child_state.entity_id) ump._child_state.entity_id)
self.mock_mp_2._state = STATE_PLAYING self.mock_mp_2._state = STATE_PLAYING
self.mock_mp_2.update_ha_state() self.mock_mp_2.update_ha_state()
ump.update_state() ump.update_state()
self.assertEqual(self.mock_mp_1.entity_id, self.assertEqual(self.mock_mp_1.entity_id,
ump.active_child_state.entity_id) ump._child_state.entity_id)
self.mock_mp_1._state = STATE_OFF self.mock_mp_1._state = STATE_OFF
self.mock_mp_1.update_ha_state() self.mock_mp_1.update_ha_state()
ump.update_state() ump.update_state()
self.assertEqual(self.mock_mp_2.entity_id, self.assertEqual(self.mock_mp_2.entity_id,
ump.active_child_state.entity_id) ump._child_state.entity_id)
def test_name(self): def test_name(self):
""" test name property """ """ test name property """