Verifying that we can write XMP UUIDs.

This commit is contained in:
jevans 2013-10-27 18:13:42 -04:00
commit 727c4dd2ea
2 changed files with 48 additions and 1 deletions

View file

@ -254,3 +254,19 @@ nemo_xmp_box = """UUID Box (uuid) @ (77, 3146)
</rdf:Description>
</rdf:RDF>
</ns0:xmpmeta>"""
SimpleRDF = """<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about='Test:XMPCoreCoverage/kSimpleRDF'
xmlns:ns1='ns:test1/' xmlns:ns2='ns:test2/'>
<ns1:SimpleProp>Simple value</ns1:SimpleProp>
<ns1:Distros>
<rdf:Bag>
<rdf:li>Suse</rdf:li>
<rdf:li>Fedora</rdf:li>
</rdf:Bag>
</ns1:Distros>
</rdf:Description>
</rdf:RDF>"""

View file

@ -12,9 +12,11 @@
import os
import re
import shutil
import struct
import sys
import tempfile
import uuid
import warnings
from xml.etree import cElementTree as ET
@ -35,9 +37,38 @@ else:
import glymur
from glymur import Jp2k
from .fixtures import OPJ_DATA_ROOT, opj_data_file, nemo_xmp_box
from .fixtures import OPJ_DATA_ROOT, opj_data_file, SimpleRDF
class TestUUIDXMP(unittest.TestCase):
"""Tests for UUIDs of XMP type."""
def setUp(self):
self.jp2file = glymur.data.nemo()
def tearDown(self):
pass
def test_append(self):
"""Should be able to append an XMP UUID box."""
the_uuid = uuid.UUID('be7acfcb-97a9-42e8-9c71-999491e3afac')
raw_data = SimpleRDF.encode('utf-8')
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
shutil.copyfile(self.jp2file, tfile.name)
jp2 = Jp2k(tfile.name)
ubox = glymur.jp2box.UUIDBox(the_uuid=the_uuid, raw_data=raw_data)
jp2.append(ubox)
# Should be two UUID boxes now.
expected_ids = ['jP ', 'ftyp', 'jp2h', 'uuid', 'jp2c', 'uuid']
actual_ids = [b.box_id for b in jp2.box]
self.assertEqual(actual_ids, expected_ids)
# The data should be an XMP packet, which gets interpreted as
# an ElementTree.
self.assertTrue(isinstance(jp2.box[-1].data.packet,
ET.ElementTree))
class TestUUIDExif(unittest.TestCase):
"""Tests for UUIDs of Exif type."""