def test_licence(self): """ 1) Set CC license 1b) getlicense 2) Set arbitrary licence 2b) Get license 3) export XMP """ uuid = self.uuid # 1) set CC license # note: "license" becomes "License" (exiftool peculiarity followed by custom tags for consistency) res = self.app.get("/setLicense/%s"%uuid,{'license':'CC-SA'}).json self.assertEqual ( res["error"], 0) # test result with loadmetadata res = self.app.get("/loadMetadata/%s"%uuid,{'group':'XMP-cc'}).json self.assertEqual(res["License"], configuration.getCCMap()["CC-SA"]) # test result with getlicense res = self.app.get("/getLicense/%s"%uuid).json self.assertEqual(res["license"], configuration.getCCMap()["CC-SA"]) # 2) Set arbitrary license res = self.app.get("/setLicense/%s"%uuid,{'license':'Arbitrary license'}).json self.assertEqual ( res["error"], 0) # test result with loadmetadata res = self.app.get("/loadMetadata/%s"%uuid,{'group':'Custom'}).json self.assertEqual(res["License"], "Arbitrary license") # test result with getlicense after deleting conflicting licenses res = self.app.post("/saveMetadata/%s"%uuid,{'metadata':'{"License":""}'}).json self.assertEqual ( res["error"], 0) res = self.app.get("/getLicense/%s"%uuid).json self.assertEqual(res["license"], "Arbitrary license") # 3) Export XMP res = self.app.get("/export/%s"%uuid).body
def setlicense(self, lic): """ Set the license of the media data as follows: 1) If the license is CC then it is added as an XMP-cc tag 2) Otherwise it is added as a value of custom tag "license" Args: lic: License string Throws: ExifException """ ccmap = configuration.getCCMap() if ( ccmap.has_key(lic) ): # we have a CC license if (lic == "Default"): # if license is default then check if another exists or use CC-Zero if ( self.mediamd.has_key("License")): log.info("mediafactory.setlicense: leaving existing license: " + self.mediamd["License"]) return True lic = "Zero" log.info("mediafactory.setlicense: defaulting to CC-Zero") # Applies to all CC licenses self.update({"License":ccmap[lic]}, group="XMP-cc") log.debug("setLicense: Saved CC licence " + lic) else: # Applies to all arbitrary licenses self.update({"License":lic}, group="Custom") log.debug("setLicense: Saved arbitrary licence " + lic) return True