コード例 #1
0
 def _test_invalid_picture(self, invalid_picture_data):
     png_data = create_fake_png(b'x')
     tags = {
         'WM/Picture': [
             ASFByteArrayAttribute(invalid_picture_data),
             ASFByteArrayAttribute(asf.pack_image(
                 "image/png", png_data))
         ]
     }
     save_raw(self.filename, tags)
     metadata = load_metadata(self.filename)
     self.assertEqual(1, len(metadata.images))
     self.assertEqual(png_data, metadata.images[0].data)
コード例 #2
0
    def test_pack_and_unpack_image(self):
        mime = 'image/png'
        image_data = create_fake_png(b'x')
        image_type = 4
        description = 'testing'
        tag_data = asf.pack_image(mime, image_data, image_type, description)
        expected_length = 5 + 2 * len(mime) + 2 + 2 * len(description) + 2 + len(image_data)
        self.assertEqual(tag_data[0], image_type)
        self.assertEqual(len(tag_data), expected_length)
        self.assertEqual(image_data, tag_data[-len(image_data):])

        unpacked = asf.unpack_image(tag_data)
        self.assertEqual(mime, unpacked[0])
        self.assertEqual(image_data, unpacked[1])
        self.assertEqual(image_type, unpacked[2])
        self.assertEqual(description, unpacked[3])
コード例 #3
0
 def test_pack_image(self):
     for args, expected in self.test_cases:
         self.assertEqual(expected, asf.pack_image(*args))