Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson committed May 9, 2016
1 parent 755b13c commit 75016f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions RFXtrx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ def send_off(self, transport):
self.send_onoff(transport, False)

def send_openclosestop(self, transport, command):
""" Send an 'Open' or a 'Close' or a 'Stop' command using the given transport """
""" Send an 'Open' or a 'Close' or a 'Stop' command
using the given transport """
if self.packettype == 0x14: # Lighting5
if command not in [0x0d, 0x0e, 0x0f]:
raise ValueError(command, "is not an 'open', 'close' or 'stop' packet in Lighting5")
raise ValueError(command, "is not a relay packet in Lighting5")
pkt = lowlevel.Lighting5()
pkt.set_transmit(self.subtype, 0, self.id_combined, self.unitcode,
command, 0x00)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def test_format_packet(self):
event = core.transport.parse(bytes_array)
event.device.send_on(core.transport)
event.device.send_off(core.transport)
event.device.send_open(core.transport)
event.device.send_close(core.transport)
event.device.send_stop(core.transport)
self.assertRaises(ValueError,event.device.send_openclosestop,core.transport,0x0c)
self.assertRaises(ValueError,event.device.send_dim,core.transport,150)
self.assertRaises(ValueError,event.device.send_dim,core.transport,-1)
event.device.send_dim(core.transport,50)
Expand Down Expand Up @@ -324,5 +328,3 @@ def test_receive(self):
self.assertEquals(RFXtrx.StatusEvent, type(event))
self.assertEquals(event.__str__(),"<class 'RFXtrx.StatusEvent'> device=[Status [subtype=433.92MHz, firmware=69, devices=['ac', 'arc', 'hideki', 'homeeasy', 'lacrosse', 'oregon', 'x10']]]")
core.close_connection()


0 comments on commit 75016f7

Please sign in to comment.