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_line.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)
def test_setup(self): """Test sensor setup.""" config = {'name': 'Test', 'unit_of_measurement': 'in', 'command': 'echo 5'} devices = [] def add_dev_callback(devs): """Add callback to add devices.""" for dev in devs: devices.append(dev) command_line.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)
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
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
def test_setup_bad_config(self): """ Test setup with a bad configuration. """ config = {} devices = [] def add_dev_callback(devs): """ callback to add device """ for dev in devs: devices.append(dev) self.assertFalse(command_line.setup_platform( self.hass, config, add_dev_callback)) self.assertEqual(0, len(devices))
def test_setup_bad_config(self): """ Test setup with a bad configuration. """ config = {} devices = [] def add_dev_callback(devs): """ callback to add device """ for dev in devs: devices.append(dev) self.assertFalse( command_line.setup_platform(self.hass, config, add_dev_callback)) self.assertEqual(0, len(devices))