Update rfxtrx tests to handle new config
This commit is contained in:
parent
74022a3978
commit
55b51cb3fa
6 changed files with 179 additions and 111 deletions
|
@ -29,9 +29,8 @@ class TestLightRfxtrx(unittest.TestCase):
|
|||
'light': {'platform': 'rfxtrx',
|
||||
'automatic_add': True,
|
||||
'devices':
|
||||
{'213c7f216': {
|
||||
{'0b1100cd0213c7f210010f51': {
|
||||
'name': 'Test',
|
||||
'packetid': '0b1100cd0213c7f210010f51',
|
||||
rfxtrx_core.ATTR_FIREEVENT: True}}}}))
|
||||
|
||||
self.assertTrue(_setup_component(self.hass, 'light', {
|
||||
|
@ -62,7 +61,7 @@ class TestLightRfxtrx(unittest.TestCase):
|
|||
'devices': {}}}))
|
||||
self.assertEqual(0, len(rfxtrx_core.RFX_DEVICES))
|
||||
|
||||
def test_one_light(self):
|
||||
def test_old_config(self):
|
||||
"""Test with 1 light."""
|
||||
self.assertTrue(_setup_component(self.hass, 'light', {
|
||||
'light': {'platform': 'rfxtrx',
|
||||
|
@ -76,7 +75,50 @@ class TestLightRfxtrx(unittest.TestCase):
|
|||
rfxtrxmod.Core("", transport_protocol=rfxtrxmod.DummyTransport)
|
||||
|
||||
self.assertEqual(1, len(rfxtrx_core.RFX_DEVICES))
|
||||
entity = rfxtrx_core.RFX_DEVICES['123efab1']
|
||||
entity = rfxtrx_core.RFX_DEVICES['213c7f216']
|
||||
self.assertEqual('Test', entity.name)
|
||||
self.assertEqual('off', entity.state)
|
||||
self.assertTrue(entity.assumed_state)
|
||||
self.assertEqual(entity.signal_repetitions, 1)
|
||||
self.assertFalse(entity.should_fire_event)
|
||||
self.assertFalse(entity.should_poll)
|
||||
|
||||
self.assertFalse(entity.is_on)
|
||||
|
||||
entity.turn_on()
|
||||
self.assertTrue(entity.is_on)
|
||||
self.assertEqual(entity.brightness, 255)
|
||||
|
||||
entity.turn_off()
|
||||
self.assertFalse(entity.is_on)
|
||||
self.assertEqual(entity.brightness, 0)
|
||||
|
||||
entity.turn_on(brightness=100)
|
||||
self.assertTrue(entity.is_on)
|
||||
self.assertEqual(entity.brightness, 100)
|
||||
|
||||
entity.turn_on(brightness=10)
|
||||
self.assertTrue(entity.is_on)
|
||||
self.assertEqual(entity.brightness, 10)
|
||||
|
||||
entity.turn_on(brightness=255)
|
||||
self.assertTrue(entity.is_on)
|
||||
self.assertEqual(entity.brightness, 255)
|
||||
|
||||
def test_one_light(self):
|
||||
"""Test with 1 light."""
|
||||
self.assertTrue(_setup_component(self.hass, 'light', {
|
||||
'light': {'platform': 'rfxtrx',
|
||||
'devices':
|
||||
{'0b1100cd0213c7f210010f51': {
|
||||
'name': 'Test'}}}}))
|
||||
|
||||
import RFXtrx as rfxtrxmod
|
||||
rfxtrx_core.RFXOBJECT =\
|
||||
rfxtrxmod.Core("", transport_protocol=rfxtrxmod.DummyTransport)
|
||||
|
||||
self.assertEqual(1, len(rfxtrx_core.RFX_DEVICES))
|
||||
entity = rfxtrx_core.RFX_DEVICES['213c7f216']
|
||||
self.assertEqual('Test', entity.name)
|
||||
self.assertEqual('off', entity.state)
|
||||
self.assertTrue(entity.assumed_state)
|
||||
|
@ -112,15 +154,12 @@ class TestLightRfxtrx(unittest.TestCase):
|
|||
'light': {'platform': 'rfxtrx',
|
||||
'signal_repetitions': 3,
|
||||
'devices':
|
||||
{'123efab1': {
|
||||
'name': 'Test',
|
||||
'packetid': '0b1100cd0213c7f230010f71'},
|
||||
'118cdea2': {
|
||||
'name': 'Bath',
|
||||
'packetid': '0b1100100118cdea02010f70'},
|
||||
'213c7f216': {
|
||||
'name': 'Living',
|
||||
'packetid': '0b1100100118cdea02010f70'}}}}))
|
||||
{'0b1100cd0213c7f230010f71': {
|
||||
'name': 'Test'},
|
||||
'0b1100100118cdea02010f70': {
|
||||
'name': 'Bath'},
|
||||
'0b1100101118cdea02010f70': {
|
||||
'name': 'Living'}}}}))
|
||||
|
||||
self.assertEqual(3, len(rfxtrx_core.RFX_DEVICES))
|
||||
device_num = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue