mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Added tests for RFxtrx device, updated rfxtrx to ver 0.5, fixed bug in setting brightness for rfxtrx light
This commit is contained in:
60
tests/components/test_rfxtrx.py
Normal file
60
tests/components/test_rfxtrx.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
tests.components.test_rfxtrx
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests Rfxtrx component.
|
||||
"""
|
||||
# pylint: disable=too-many-public-methods,protected-access
|
||||
import unittest
|
||||
import time
|
||||
|
||||
from homeassistant.components import rfxtrx as rfxtrx
|
||||
from homeassistant.components.sensor import rfxtrx as rfxtrx_sensor
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
class TestSun(unittest.TestCase):
|
||||
""" Test the sun module. """
|
||||
|
||||
def setUp(self):
|
||||
""" setup hass """
|
||||
self.hass = get_test_home_assistant(0)
|
||||
|
||||
def tearDown(self):
|
||||
""" Stop down stuff we started. """
|
||||
rfxtrx.RECEIVED_EVT_SUBSCRIBERS = []
|
||||
rfxtrx.RFX_DEVICES = {}
|
||||
rfxtrx.RFXOBJECT = None
|
||||
self.hass.stop()
|
||||
|
||||
def test_default_config(self):
|
||||
""" Test config """
|
||||
self.assertTrue(rfxtrx.setup(self.hass, {
|
||||
'rfxtrx': {
|
||||
'device': '/dev/serial/by-id/usb' +
|
||||
'-RFXCOM_RFXtrx433_A1Y0NJGR-if00-port0',
|
||||
'dummy': True}
|
||||
}))
|
||||
|
||||
config = {'devices': {}}
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
rfxtrx_sensor.setup_platform(self.hass, config, add_dev_callback)
|
||||
|
||||
while len(rfxtrx.RFX_DEVICES) < 2:
|
||||
time.sleep(0.1)
|
||||
|
||||
self.assertEquals(len(rfxtrx.RFXOBJECT.sensors()), 2)
|
||||
self.assertEquals(len(devices), 2)
|
||||
|
||||
def test_config_failing(self):
|
||||
""" Test config """
|
||||
self.assertFalse(rfxtrx.setup(self.hass, {
|
||||
'rfxtrx': {}
|
||||
}))
|
||||
Reference in New Issue
Block a user