binary_sensor sensor_class to entity device_class (#5860)

* binary_sensor sensor_class to entity device_class

* Linter fixes

* Should be it
This commit is contained in:
Adam Mills 2017-02-10 23:46:15 -05:00 committed by Paulus Schoutsen
parent 67957cbfa8
commit e877d572f5
36 changed files with 242 additions and 199 deletions

View file

@ -47,32 +47,32 @@ class TestSensorMQTT(unittest.TestCase):
state = self.hass.states.get('binary_sensor.test')
self.assertEqual(STATE_OFF, state.state)
def test_valid_sensor_class(self):
def test_valid_device_class(self):
"""Test the setting of a valid sensor class."""
self.hass.config.components = set(['mqtt'])
assert setup_component(self.hass, binary_sensor.DOMAIN, {
binary_sensor.DOMAIN: {
'platform': 'mqtt',
'name': 'test',
'sensor_class': 'motion',
'device_class': 'motion',
'state_topic': 'test-topic',
}
})
state = self.hass.states.get('binary_sensor.test')
self.assertEqual('motion', state.attributes.get('sensor_class'))
self.assertEqual('motion', state.attributes.get('device_class'))
def test_invalid_sensor_class(self):
def test_invalid_device_class(self):
"""Test the setting of an invalid sensor class."""
self.hass.config.components = set(['mqtt'])
assert setup_component(self.hass, binary_sensor.DOMAIN, {
binary_sensor.DOMAIN: {
'platform': 'mqtt',
'name': 'test',
'sensor_class': 'abc123',
'device_class': 'abc123',
'state_topic': 'test-topic',
}
})
state = self.hass.states.get('binary_sensor.test')
self.assertIsNone(state.attributes.get('sensor_class'))
self.assertIsNone(state)