mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Added tests for command sensor
Added tests to create and check basic functionality of command sensor.
This commit is contained in:
parent
2651021461
commit
97e867052d
45
tests/components/sensor/test_command_sensor.py
Normal file
45
tests/components/sensor/test_command_sensor.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
"""
|
||||||
|
tests.components.sensor.command_sensor
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Tests command sensor.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import homeassistant.core as ha
|
||||||
|
from homeassistant.components.sensor import command_sensor
|
||||||
|
|
||||||
|
|
||||||
|
class TestCommandSensorSensor(unittest.TestCase):
|
||||||
|
""" Test the Template sensor. """
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.hass = ha.HomeAssistant()
|
||||||
|
|
||||||
|
self.config = {'name': 'Test',
|
||||||
|
'unit_of_measurement': 'in',
|
||||||
|
'command': 'echo 5',
|
||||||
|
'value_template': '{{ value }}'}
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
""" Stop down stuff we started. """
|
||||||
|
self.hass.stop()
|
||||||
|
|
||||||
|
def test_setup(self):
|
||||||
|
""" Test sensor setup """
|
||||||
|
devices = []
|
||||||
|
|
||||||
|
def add_dev_callback(devs):
|
||||||
|
""" callback to add device """
|
||||||
|
for dev in devs:
|
||||||
|
devices.append(dev)
|
||||||
|
|
||||||
|
command_sensor.setup_platform(
|
||||||
|
self.hass, self.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)
|
Loading…
x
Reference in New Issue
Block a user