def test_setup(self):
        """ Test sensor setup """
        config = {'name': 'Test',
                  'unit_of_measurement': 'in',
                  'command': 'echo 5'}
        devices = []

        def add_dev_callback(devs):
            """ callback to add device """
            for dev in devs:
                devices.append(dev)

        command_sensor.setup_platform(
            self.hass, config, add_dev_callback)

        self.assertEqual(1, len(devices))
        entity = devices[0]
        self.assertEqual('Test', entity.name)
        self.assertEqual('in', entity.unit_of_measurement)
        self.assertEqual('5', entity.state)
Exemplo n.º 2
0
    def test_setup(self):
        """ Test sensor setup """
        config = {
            'name': 'Test',
            'unit_of_measurement': 'in',
            'command': 'echo 5'
        }
        devices = []

        def add_dev_callback(devs):
            """ callback to add device """
            for dev in devs:
                devices.append(dev)

        command_sensor.setup_platform(self.hass, config, add_dev_callback)

        self.assertEqual(1, len(devices))
        entity = devices[0]
        self.assertEqual('Test', entity.name)
        self.assertEqual('in', entity.unit_of_measurement)
        self.assertEqual('5', entity.state)
Exemplo n.º 3
0
    def test_setup_bad_config(self):
        """ Test setup with a bad config """
        config = {}

        devices = []

        def add_dev_callback(devs):
            """ callback to add device """
            for dev in devs:
                devices.append(dev)

        self.assertFalse(
            command_sensor.setup_platform(self.hass, config, add_dev_callback))

        self.assertEqual(0, len(devices))
    def test_setup_bad_config(self):
        """ Test setup with a bad config """
        config = {}

        devices = []

        def add_dev_callback(devs):
            """ callback to add device """
            for dev in devs:
                devices.append(dev)

        self.assertFalse(command_sensor.setup_platform(
            self.hass, config, add_dev_callback))

        self.assertEqual(0, len(devices))