def test_bytes_uncompressed(self): attachment = AttachmentBlock( file_name=self.filename, data=self.data, embedded=True, compressed=False, ) attachment.comment = self.comment stream = BytesIO() stream.write(b"\0") blocks = [] attachment.to_blocks(1, blocks, {}) for block in blocks: stream.write(bytes(block)) address = attachment.address block = AttachmentBlock(address=address, stream=stream) self.assertEqual(block.comment, self.comment) self.assertEqual(block.file_name, self.filename) self.assertEqual(block.extract(), self.data)
def test_read_uncompressed(self): self.uncompressed.seek(0) block = AttachmentBlock(address=97, stream=self.uncompressed) self.assertEqual(block.file_name, self.filename) self.assertEqual(block.extract(), self.data) self.assertEqual(block.comment, self.comment)