示例#1
0
    def test_setup(self):
        """Test sensor setup."""
        config = {'name': 'Test',
                  'unit_of_measurement': 'in',
                  'command': 'echo 5',
                  'command_timeout': 15
                  }
        devices = []

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

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

        assert 1 == len(devices)
        entity = devices[0]
        entity.update()
        assert 'Test' == entity.name
        assert 'in' == entity.unit_of_measurement
        assert '5' == entity.state
示例#2
0
文件: test_sensor.py 项目: 1e1/core-1
    def test_setup(self):
        """Test sensor setup."""
        config = {
            "name": "Test",
            "unit_of_measurement": "in",
            "command": "echo 5",
            "command_timeout": 15,
        }
        devices = []

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

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

        assert len(devices) == 1
        entity = devices[0]
        entity.update()
        assert entity.name == "Test"
        assert entity.unit_of_measurement == "in"
        assert entity.state == "5"