Example #1
0
 def test_setup_invalid_device(self):
     """"Test the setup with invalid devices."""
     config = {
         'sensors': {
             'foo bar': {},
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
Example #2
0
 def test_setup_invalid_missing_template(self):
     """"Test setup with invalid and missing template."""
     config = {
         'sensors': {
             'test': {
                 'sensor_class': 'motion',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
Example #3
0
 def test_setup_invalid_sensor_class(self):
     """"Test setup with invalid sensor class."""
     config = {
         'sensors': {
             'test': {
                 'value_template': '{{ foo }}',
                 'sensor_class': 'foobarnotreal',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
Example #4
0
 def test_setup(self, mock_template):
     """"Test the setup."""
     config = {
         'sensors': {
             'test': {
                 'friendly_name': 'virtual thingy',
                 'value_template': '{{ foo }}',
                 'sensor_class': 'motion',
             },
         }
     }
     hass = mock.MagicMock()
     add_devices = mock.MagicMock()
     result = template.setup_platform(hass, config, add_devices)
     self.assertTrue(result)
     mock_template.assert_called_once_with(hass, 'test', 'virtual thingy',
                                           'motion', '{{ foo }}', MATCH_ALL)
     add_devices.assert_called_once_with([mock_template.return_value])
Example #5
0
 def test_setup_no_sensors(self):
     """"Test setup with no sensors."""
     config = {}
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)