def test_make_open(self): buf = bytearray(range(32)) # Start with junk in the buffer. seq = 79 drive = b'A' filename = b'REALTIME.000' p = stentura._make_open(buf, seq, drive, filename) for_crc = [seq, 20 + len(filename), 0, stentura._OPEN, 0, ord(drive), 0, 0, 0, 0, 0, 0, 0, 0, 0] crc = stentura._crc(for_crc) data_crc = stentura._crc(filename) expected = bytearray([1] + for_crc + [crc & 0xFF, crc >> 8]) expected.extend(filename) expected.extend([data_crc & 0xFF, data_crc >> 8]) self.assertEqual(p, expected)
def test_make_open(self): buf = array.array('B', [3] * 18) # Start with junk in the buffer. seq = 79 drive = 'A' filename = 'REALTIME.000' p = stentura._make_open(buf, seq, drive, filename) for_crc = [seq, 20 + len(filename), 0, stentura._OPEN, 0, ord(drive), 0, 0, 0, 0, 0, 0, 0, 0, 0] crc = stentura._crc(for_crc) data_crc = stentura._crc(filename) expected = ([1] + for_crc + [crc & 0xFF, crc >> 8] + [ord(b) for b in filename] + [data_crc & 0xFF, data_crc >> 8]) self.assertSequenceEqual(p, [chr(b) for b in expected])
def test_make_open(self): buf = array.array('B', [3] * 18) # Start with junk in the buffer. seq = 79 drive = 'A' filename = 'REALTIME.000' p = stentura._make_open(buf, seq, drive, filename) for_crc = [ seq, 20 + len(filename), 0, stentura._OPEN, 0, ord(drive), 0, 0, 0, 0, 0, 0, 0, 0, 0 ] crc = stentura._crc(for_crc) data_crc = stentura._crc(filename) expected = ([1] + for_crc + [crc & 0xFF, crc >> 8] + [ord(b) for b in filename] + [data_crc & 0xFF, data_crc >> 8]) self.assertSequenceEqual(p, [chr(b) for b in expected])