8 Tests the XBeeBase superclass module for XBee API conformance.    16     XBeeBase class should properly._write binary data in a valid API    17     frame to a given serial device.    22         _write method should write the expected data to the serial    31         expected_frame = 
'\x7E\x00\x01\x00\xFF'    32         self.assertEqual(device.data, expected_frame)
    36         _write method should write the expected data to the serial    42         xbee._write(
'\x00\x01\x02')
    45         expected_frame = 
'\x7E\x00\x03\x00\x01\x02\xFC'    46         self.assertEqual(device.data, expected_frame)
    50         _write method should write the expected data to the serial    56         xbee._write(
'\x7E\x01\x7D\x11\x13')
    59         expected_frame = 
'\x7E\x00\x05\x7D\x5E\x01\x7D\x5D\x7D\x31\x7D\x33\xDF'    60         self.assertEqual(device.data, expected_frame)
    64     XBeeBase class should properly read and extract data from a valid    69         _wait_for_frame should properly read a frame of data    74         frame = xbee._wait_for_frame()
    75         self.assertEqual(frame.data, 
'\x00')
    79         _wait_for_frame should skip invalid data    82             '\x7E\x00\x01\x00\xFA' + 
'\x7E\x00\x01\x05\xFA')
    85         frame = xbee._wait_for_frame()
    86         self.assertEqual(frame.data, 
'\x05')
    90         _wait_for_frame should properly read a frame of data    91         Verify that API mode 2 escaped bytes are read correctly    93         device = 
FakeReadDevice(
'\x7E\x00\x04\x7D\x5E\x7D\x5D\x7D\x31\x7D\x33\xE0')
    97         frame = xbee._wait_for_frame()
    98         self.assertEqual(frame.data, 
'\x7E\x7D\x11\x13')
   102     In order to properly use the XBeeBase class for most situations,   103     it must be subclassed with the proper attributes definined. If   104     this is not the case, then a NotImplemented exception should be   105     raised as appropriate.   110         Set up a base class XBeeBase object which does not have    111         api_commands or api_responses defined   117         _build_command should raise NotImplemented   119         self.assertRaises(NotImplementedError, self.
xbee._build_command, 
"at")
   123         split_command should raise NotImplemented   125         self.assertRaises(NotImplementedError, self.
xbee._split_response, 
"\00")
   129         Shorthand calls should raise NotImplementedError   133         except NotImplementedError:
   136             self.fail(
"Shorthand call on XBeeBase base class should raise NotImplementedError")
   140     XBeeBase constructor should accept an optional callback function    141     argument. When provided, this will put the module into a threaded   142     mode, in which it will call the provided function with any API   145     As it would be very difficult to sanely test an asynchonous callback   146     routine with a synchronous test process, proper callback behavior   147     is not tested automatically at this time. Theoretically, the   148     callback implementation logic is simple, but use it at your own risk.   162         XBeeBase constructor should accept a callback function   168     Ensures that XBeeBase objects are properly constructed   176         Even when a callback method is not supplied to the XBeeBase   177         constructor, it must be properly initalized as a   178         threading.Thread object   180         self.assertFalse(self.
base.is_alive())
   182 if __name__ == 
'__main__':
 def test_provide_callback(self)
def test_thread_always_initialized(self)
def test_read_invalid_followed_by_valid(self)
def test_build_command(self)
def test_write_escaped(self)
def test_split_response(self)
def test_write_again(self)
def test_read_escaped(self)