Nick Raptis avatar Nick Raptis committed 88edf47

Updated tests with new behaviour.

Comments (0)

Files changed (3)

TestFirmware7bit.diff

+# HG changeset patch
+# Parent f240bc4e31bba4a706a44ae59b36f022081c0aad
+tests: Updated Firmware tests for 7bit bytes
+
+diff -r f240bc4e31bb -r 6afee073fe8a tests.py
+--- a/tests.py	Tue May 17 00:04:54 2011 +0300
++++ b/tests.py	Tue May 17 00:06:21 2011 +0300
+@@ -58,7 +58,9 @@
+         
+     def test_handle_report_firmware(self):
+         self.assertEqual(self.board.firmware, None)
+-        data = [2, 1] + [ord(x) for x in 'Firmware_name']
++        data = [2, 1]
++        for x in 'Firmware_name':
++            data += [ord(x), 0]
+         self.board._handle_report_firmware(*data)
+         self.assertEqual(self.board.firmware, 'Firmware_name')
+         self.assertEqual(self.board.firmata_version, (2, 1))
+@@ -123,8 +125,10 @@
+         msg = [chr(pyfirmata.START_SYSEX), 
+                chr(pyfirmata.REPORT_FIRMWARE), 
+                chr(2), 
+-               chr(1)] + [i for i in 'Firmware_name'] + \
+-              [chr(pyfirmata.END_SYSEX)]
++               chr(1)]
++        for i in 'Firmware_name':
++            msg += [i, chr(0)]
++        msg += [chr(pyfirmata.END_SYSEX)]
+         self.board.sp.write(msg)
+         self.board.iterate()
+         self.assertEqual(self.board.firmware, 'Firmware_name')
+@@ -165,7 +169,9 @@
+         self.assert_serial(*sysex)
+         
+     def test_receive_sysex_message(self):
+-        sysex = (chr(0xF0), chr(0x79), chr(2), chr(1), 'a', 'b', 'c', chr(0xF7))
++        sysex = (chr(0xF0), chr(0x79), chr(2), chr(1),
++         'a', chr(0), 'b', chr(0), 'c', chr(0),
++         chr(0xF7))
+         self.board.sp.write(sysex)
+         while len(self.board.sp):
+             self.board.iterate()

TestMockupInWaiting.diff

+# HG changeset patch
+# Parent 651f06a045e52af82b28a1544e32404c1befd7e3
+tests: Add pyserial's inWaiting to mockup
+
+diff -r 651f06a045e5 -r f240bc4e31bb pyfirmata/mockup.py
+--- a/pyfirmata/mockup.py	Mon May 16 23:04:43 2011 +0300
++++ b/pyfirmata/mockup.py	Tue May 17 00:04:54 2011 +0300
+@@ -12,6 +12,8 @@
+     >>> s.write(chr(100))
+     >>> s.write('blaat')
+     >>> s.write(100000)
++    >>> s.inWaiting()
++    3
+     >>> s.read(2)
+     ['d', 'blaat']
+     >>> s.read()
+@@ -20,6 +22,8 @@
+     ''
+     >>> s.read(2)
+     ['', '']
++    >>> s.inWaiting()
++    0
+     >>> s.close()
+     """
+     def __init__(self, port, baudrate, timeout=0.02):
+@@ -49,6 +53,9 @@
+         else:
+             self.append(value)
+             
++    def inWaiting(self):
++        return len(self)
++
+     def close(self):
+         self.clear()
+         
+Available.diff
+TestMockupInWaiting.diff
 FirmwareString.diff
-Available.diff
+TestFirmware7bit.diff
 WaitAndInit.diff
 GetBoardBug.diff
 # Placed by Bitbucket
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.