Use voluptuous for Command line platforms (#2968)

* Migrate to voluptuous

* Fix pylint issues

* Remove FIXME

* Split setup test

* Test with bootstrap

* Remove lon and lat

* Fix pylint issues
This commit is contained in:
Fabian Affolter 2016-09-02 16:09:09 +02:00 committed by Teagan Glenn
parent 81628b01c2
commit 40c71b5d96
11 changed files with 199 additions and 134 deletions

View file

@ -2,7 +2,7 @@
import unittest
from homeassistant.components.sensor import command_line
from homeassistant import bootstrap
from tests.common import get_test_home_assistant
@ -21,7 +21,8 @@ class TestCommandSensorSensor(unittest.TestCase):
"""Test sensor setup."""
config = {'name': 'Test',
'unit_of_measurement': 'in',
'command': 'echo 5'}
'command': 'echo 5'
}
devices = []
def add_dev_callback(devs):
@ -29,8 +30,7 @@ class TestCommandSensorSensor(unittest.TestCase):
for dev in devs:
devices.append(dev)
command_line.setup_platform(
self.hass, config, add_dev_callback)
command_line.setup_platform(self.hass, config, add_dev_callback)
self.assertEqual(1, len(devices))
entity = devices[0]
@ -40,19 +40,13 @@ class TestCommandSensorSensor(unittest.TestCase):
def test_setup_bad_config(self):
"""Test setup with a bad configuration."""
config = {}
config = {'name': 'test',
'platform': 'not_command_line',
}
devices = []
def add_dev_callback(devs):
"""Add a callback to add devices."""
for dev in devs:
devices.append(dev)
self.assertFalse(command_line.setup_platform(
self.hass, config, add_dev_callback))
self.assertEqual(0, len(devices))
self.assertFalse(bootstrap.setup_component(self.hass, 'test', {
'command_line': config,
}))
def test_template(self):
"""Test command sensor with template."""