예제 #1
0
 def test_setup_invalid_device(self):
     config = {
         'sensors': {
             'foo bar': {},
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #2
0
 def test_setup_invalid_device(self):
     config = {
         'sensors': {
             'foo bar': {},
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #3
0
 def test_setup_invalid_missing_template(self):
     config = {
         'sensors': {
             'test': {
                 'sensor_class': 'motion',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #4
0
 def test_setup_invalid_missing_template(self):
     config = {
         'sensors': {
             'test': {
                 'sensor_class': 'motion',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #5
0
 def test_setup_invalid_sensor_class(self):
     config = {
         'sensors': {
             'test': {
                 'value_template': '{{ foo }}',
                 'sensor_class': 'foobarnotreal',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #6
0
 def test_setup_invalid_sensor_class(self):
     config = {
         'sensors': {
             'test': {
                 'value_template': '{{ foo }}',
                 'sensor_class': 'foobarnotreal',
             },
         },
     }
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #7
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])
예제 #8
0
 def test_setup(self, mock_template):
     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 }}')
     add_devices.assert_called_once_with([mock_template.return_value])
예제 #9
0
 def test_setup(self, mock_template):
     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 }}')
     add_devices.assert_called_once_with([mock_template.return_value])
예제 #10
0
 def test_setup(self, mock_template):
     """"Test the setup."""
     tpl = template_hlpr.Template('{{ foo }}', self.hass)
     config = PLATFORM_SCHEMA({
         'platform': 'template',
         'sensors': {
             'test': {
                 'friendly_name': 'virtual thingy',
                 'value_template': tpl,
                 'sensor_class': 'motion',
                 'entity_id': 'test'
             },
         }
     })
     add_devices = mock.MagicMock()
     result = template.setup_platform(self.hass, config, add_devices)
     self.assertTrue(result)
     mock_template.assert_called_once_with(
         self.hass, 'test', 'virtual thingy', 'motion', tpl, 'test')
     add_devices.assert_called_once_with([mock_template.return_value])
예제 #11
0
 def test_setup(self, mock_template):
     """"Test the setup."""
     tpl = template_hlpr.Template('{{ foo }}', self.hass)
     config = PLATFORM_SCHEMA({
         'platform': 'template',
         'sensors': {
             'test': {
                 'friendly_name': 'virtual thingy',
                 'value_template': tpl,
                 'sensor_class': 'motion',
                 'entity_id': 'test'
             },
         }
     })
     add_devices = mock.MagicMock()
     result = template.setup_platform(self.hass, config, add_devices)
     self.assertTrue(result)
     mock_template.assert_called_once_with(self.hass, 'test',
                                           'virtual thingy', 'motion', tpl,
                                           'test')
     add_devices.assert_called_once_with([mock_template.return_value])
예제 #12
0
 def test_setup(self, mock_template):
     """"Test the setup."""
     tpl = template_hlpr.Template("{{ foo }}", self.hass)
     config = PLATFORM_SCHEMA(
         {
             "platform": "template",
             "sensors": {
                 "test": {
                     "friendly_name": "virtual thingy",
                     "value_template": tpl,
                     "sensor_class": "motion",
                     "entity_id": "test",
                 }
             },
         }
     )
     add_devices = mock.MagicMock()
     result = template.setup_platform(self.hass, config, add_devices)
     self.assertTrue(result)
     mock_template.assert_called_once_with(self.hass, "test", "virtual thingy", "motion", tpl, "test")
     add_devices.assert_called_once_with([mock_template.return_value])
예제 #13
0
 def test_setup_no_sensors(self):
     """"Test setup with no sensors."""
     config = {}
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #14
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)
예제 #15
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)
예제 #16
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)
예제 #17
0
 def test_setup_no_sensors(self):
     """"Test setup with no sensors."""
     config = {}
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #18
0
 def test_setup_no_sensors(self):
     config = {}
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)
예제 #19
0
 def test_setup_no_sensors(self):
     config = {}
     result = template.setup_platform(None, config, None)
     self.assertFalse(result)