Esempio n. 1
0
 def test_state(self):
     """Test binary sensor state."""
     sensor = binary_sensor.BinarySensorDevice()
     assert STATE_OFF == sensor.state
     with mock.patch(
             "homeassistant.components.binary_sensor.BinarySensorDevice.is_on",
             new=False,
     ):
         assert STATE_OFF == binary_sensor.BinarySensorDevice().state
     with mock.patch(
             "homeassistant.components.binary_sensor.BinarySensorDevice.is_on",
             new=True,
     ):
         assert STATE_ON == binary_sensor.BinarySensorDevice().state
Esempio n. 2
0
 def test_state(self):
     """Test binary sensor state."""
     sensor = binary_sensor.BinarySensorDevice()
     self.assertEqual(STATE_OFF, sensor.state)
     with mock.patch(
             'homeassistant.components.binary_sensor.'
             'BinarySensorDevice.is_on',
             new=False):
         self.assertEqual(STATE_OFF,
                          binary_sensor.BinarySensorDevice().state)
     with mock.patch(
             'homeassistant.components.binary_sensor.'
             'BinarySensorDevice.is_on',
             new=True):
         self.assertEqual(STATE_ON,
                          binary_sensor.BinarySensorDevice().state)
Esempio n. 3
0
 def test_attributes(self):
     """Test binary sensor attributes."""
     sensor = binary_sensor.BinarySensorDevice()
     self.assertEqual({}, sensor.state_attributes)
     with mock.patch(
             'homeassistant.components.binary_sensor.'
             'BinarySensorDevice.sensor_class',
             new='motion'):
         self.assertEqual({'sensor_class': 'motion'},
                          sensor.state_attributes)