Update rfxtrx tests to handle new config

This commit is contained in:
Daniel 2016-04-23 19:57:36 +02:00
parent 74022a3978
commit 55b51cb3fa
6 changed files with 179 additions and 111 deletions

View file

@ -29,9 +29,8 @@ class TestSwitchRfxtrx(unittest.TestCase):
'switch': {'platform': 'rfxtrx',
'automatic_add': True,
'devices':
{'213c7f216': {
{'0b1100cd0213c7f210010f51': {
'name': 'Test',
'packetid': '0b1100cd0213c7f210010f51',
rfxtrx_core.ATTR_FIREEVENT: True}
}}}))
@ -71,17 +70,6 @@ class TestSwitchRfxtrx(unittest.TestCase):
}}}))
def test_invalid_config4(self):
self.assertFalse(_setup_component(self.hass, 'switch', {
'switch': {'platform': 'rfxtrx',
'automatic_add': True,
'devices':
{'AA3c7f216': {
'name': 'Test',
'packetid': '0b1100cd0213c7f210010f51',
rfxtrx_core.ATTR_FIREEVENT: True}
}}}))
def test_invalid_config5(self):
"""Test configuration."""
self.assertFalse(_setup_component(self.hass, 'switch', {
'switch': {'platform': 'rfxtrx',
@ -100,7 +88,7 @@ class TestSwitchRfxtrx(unittest.TestCase):
{}}}))
self.assertEqual(0, len(rfxtrx_core.RFX_DEVICES))
def test_one_switch(self):
def test_old_config(self):
"""Test with 1 switch."""
self.assertTrue(_setup_component(self.hass, 'switch', {
'switch': {'platform': 'rfxtrx',
@ -114,7 +102,34 @@ class TestSwitchRfxtrx(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)
entity.turn_off()
self.assertFalse(entity.is_on)
def test_one_switch(self):
"""Test with 1 switch."""
self.assertTrue(_setup_component(self.hass, 'switch', {
'switch': {'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)
@ -134,15 +149,12 @@ class TestSwitchRfxtrx(unittest.TestCase):
'switch': {'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