def test_from_wire_bad_input(self): raw_data = 'blahblahblahblah'.encode() with self.assertRaises(PayloadParseError): RQPacket.from_wire(raw_data) filename, mode = ('file'.encode(), 'nomode'.encode()) raw_data = b''.join((filename, b'\x00', mode, b'\x00')) with self.assertRaises(UnsupportedModeError): RQPacket.from_wire(raw_data)
def test_from_wire_good_input(self): filename, mode = ('file'.encode(), 'netascii'.encode()) raw_data = b''.join((filename, b'\x00', mode, b'\x00')) packet = RQPacket.from_wire(raw_data) self.assertEqual(filename, packet.filename) self.assertEqual(mode, packet.mode)