1# -*- coding: utf-8 -*- 2 3from system_tests import DeleteFiles, CopyFiles, CaseMeta, path 4 5 6@DeleteFiles("$xmpname") 7@CopyFiles("$data_path/exiv2-empty.jpg") 8class AdobeXmpNamespace(metaclass=CaseMeta): 9 10 url = "http://dev.exiv2.org/issues/751" 11 12 filename = path("$data_path/exiv2-empty_copy.jpg") 13 xmpname = path("$data_path/exiv2-empty_copy.xmp") 14 15 commands = [ 16 """$exiv2 -v -M"reg imageapp orig/" -M "set Xmp.imageapp.uuid abcd" $filename""", 17 "$exiv2 -f -eX $filename", 18 """$exiv2 -v -M"reg imageapp dest/" -M "set Xmp.imageapp.uuid abcd" $filename""", 19 "$exiv2 -f -eX $filename", 20 ] 21 22 def post_command_hook(self, i, command): 23 def read_xmpfile(): 24 with open(self.xmpname, "r", encoding='utf-8') as xmp: 25 return xmp.read(-1) 26 27 if i == 2 or i == 4: 28 self.assertMultiLineEqual(self.xmp_packets[i//2 - 1], read_xmpfile()) 29 30 31 xmp_packets = [ 32 """<?xpacket begin="\ufeff" id="W5M0MpCehiHzreSzNTczkc9d"?> 33<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2"> 34 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> 35 <rdf:Description rdf:about="" 36 xmlns:imageapp="orig/" 37 imageapp:uuid="abcd"/> 38 </rdf:RDF> 39</x:xmpmeta> 40<?xpacket end="w"?>""", 41 """<?xpacket begin="\ufeff" id="W5M0MpCehiHzreSzNTczkc9d"?> 42<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2"> 43 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> 44 <rdf:Description rdf:about="" 45 xmlns:imageapp="orig/" 46 imageapp:uuid="abcd"/> 47 </rdf:RDF> 48</x:xmpmeta> 49<?xpacket end="w"?>""" 50 ] 51 52 stdout = [ 53 """File 1/1: $filename 54Reg imageapp="orig/" 55Set Xmp.imageapp.uuid "abcd" (XmpText) 56""", 57 "", 58 """File 1/1: $filename 59Reg imageapp="dest/" 60Set Xmp.imageapp.uuid "abcd" (XmpText) 61""", 62 "", 63 ] 64 stderr = [ 65 "", 66 "", 67 """Warning: Updating namespace URI for imageapp from orig/ to dest/ 68""", 69 """Warning: Updating namespace URI for imageapp from dest/ to orig/ 70""", 71 ] 72 retval = [0] * 4 73