From 2d0004f46aa6844b1de7690c20b5da72fa98d760 Mon Sep 17 00:00:00 2001 From: Ryan Kraus Date: Sat, 30 Jan 2016 22:16:22 -0500 Subject: [PATCH] Another test for for command sensor Added a test for command sensors with bad configurations. --- tests/components/sensor/test_command_sensor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/components/sensor/test_command_sensor.py b/tests/components/sensor/test_command_sensor.py index 21cd10a5e46..ae6c9452d3f 100644 --- a/tests/components/sensor/test_command_sensor.py +++ b/tests/components/sensor/test_command_sensor.py @@ -42,6 +42,22 @@ class TestCommandSensorSensor(unittest.TestCase): self.assertEqual('in', entity.unit_of_measurement) self.assertEqual('5', entity.state) + 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_template(self): """ Test command sensor with template """ data = command_sensor.CommandSensorData('echo 50')