test_fake.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 """
00003 test_xbee.py
00004 
00005 By Paul Malmsten, 2010
00006 pmalmsten@gmail.com
00007 
00008 Tests fake device objects for proper functionality.
00009 """
00010 import unittest
00011 from xbee.tests.Fake import FakeReadDevice
00012 
00013 class TestFakeReadDevice(unittest.TestCase):
00014     """
00015     FakeReadDevice class should work as intended to emluate a serial 
00016     port
00017     """
00018     def setUp(self):
00019         """
00020         Create a fake read device for each test
00021         """
00022         self.device = FakeReadDevice("test")
00023     
00024     def test_read_single_byte(self):
00025         """
00026         reading one byte at a time should work as expected
00027         """
00028         self.assertEqual(self.device.read(), 't')
00029         self.assertEqual(self.device.read(), 'e')
00030         self.assertEqual(self.device.read(), 's')
00031         self.assertEqual(self.device.read(), 't')
00032         
00033     def test_read_multiple_bytes(self):
00034         """
00035         reading multiple bytes at a time should work as expected
00036         """
00037         self.assertEqual(self.device.read(3), 'tes')
00038         self.assertEqual(self.device.read(), 't')
00039         
00040     def test_read_too_many(self):
00041         """
00042         attempting to read too many bytes should raise an exception
00043         """
00044         self.assertRaises(ValueError, self.device.read, 5)


rosserial_xbee
Author(s): Adam Stambler
autogenerated on Fri Aug 28 2015 12:44:47