Exemple #1
0
    def test_open_file(self):
        # Non-existing file.
        xmpfile = XMPFiles()
        self.assertRaises(XMPError, xmpfile.open_file, '')

        xmpfile = XMPFiles()
        xmpfile.open_file(samplefiles.keys()[0])
        self.assertRaises(XMPError, xmpfile.open_file, samplefiles.keys()[0])
        self.assertRaises(XMPError, xmpfile.open_file, samplefiles.keys()[1])
        xmpfile.close_file()
        xmpfile.open_file(samplefiles.keys()[1])
        self.assertRaises(XMPError, xmpfile.open_file, samplefiles.keys()[0])

        # Open all sample files.
        for f in samplefiles.iterkeys():
            xmpfile = XMPFiles()
            xmpfile.open_file(f)

        # Try using init
        for f, fmt in samplefiles.iteritems():
            xmpfile = XMPFiles(file_path=f)

        # Try all open options
        for flg in open_flags:
            kwargs = {flg: True}

            for f, fmt in samplefiles.iteritems():
                xmpfile = XMPFiles()
                xmpfile.open_file(f, **kwargs)
 def test_avm_to_file(self):
     for f in samplefiles.iteritems():
         print f[0]
         avm_to_file(f[0], self.avm_dict, replace=True)
         retrieved_avm = avm_from_file(f[0])
         self.assertEqual(retrieved_avm, self.avm_dict, f[0])
         """
Exemple #3
0
 def test_avm_to_file(self):
     for f in samplefiles.iteritems():
         print f[0]
         avm_to_file(f[0], self.avm_dict, replace=True)
         retrieved_avm = avm_from_file(f[0])
         self.assertEqual(retrieved_avm, self.avm_dict, f[0])
         """
Exemple #4
0
 def test_can_put_xmp(self):
     for flg in open_flags:
         kwargs = {flg: True}
         for f, fmt in samplefiles.iteritems():
             # See test_exempi_error()
             if not self.flg_fmt_combi(
                     flg, fmt) and not self.exempi_problem(flg, fmt):
                 xmpfile = XMPFiles()
                 xmpfile.open_file(f, **kwargs)
                 xmp = xmpfile.get_xmp()
                 if flg == 'open_forupdate':
                     self.assert_(xmpfile.can_put_xmp(xmp))
                 else:
                     self.failIf(xmpfile.can_put_xmp(xmp))
Exemple #5
0
    def test_exempi_bad_combinations(self):
        """ 
		Certain combinations of formats and open flags will raise an XMPError when you try to open the XMP
		"""
        for flg in open_flags:
            kwargs = {flg: True}
            for f, fmt in samplefiles.iteritems():
                if not self.flg_fmt_combi(flg, fmt):
                    xmpfile = XMPFiles()
                    xmpfile.open_file(f, **kwargs)
                    xmpfile.get_xmp()
                else:
                    xmpfile = XMPFiles()
                    xmpfile.open_file(f, **kwargs)
                    self.assertRaises(XMPError, xmpfile.get_xmp)
Exemple #6
0
 def test_get_xmp(self):
     for flg in open_flags:
         kwargs = {flg: True}
         for f, fmt in samplefiles.iteritems():
             # See test_exempi_error()
             if not self.flg_fmt_combi(flg, fmt):
                 xmpfile = XMPFiles(file_path=f, **kwargs)
                 try:
                     xmp = xmpfile.get_xmp()
                     self.assert_(isinstance(xmp, XMPMeta),
                                  "Not an XMPMeta object")
                 except XMPError, e:
                     print f
                     print flg
                     print fmt
                 xmpfile.close_file()
	def test_get_xmp(self):
		for f,fmt in samplefiles.iteritems():
			xmpfile = XMPFiles( file_path=f )
			xmp = xmpfile.get_xmp()
			self.assert_( isinstance(xmp, XMPMeta), "Not an XMPMeta object" )
			xmpfile.close_file()
	def test_file_to_dict(self):
		for f,fmt in samplefiles.iteritems():
			self.assert_( file_to_dict( f ), "Expected dictionary" )
	def test_object_to_dict(self):
		for f,fmt in samplefiles.iteritems():
			xmpfile = XMPFiles( file_path=f )
			xmp = xmpfile.get_xmp()
			self.assert_( object_to_dict( xmp ), "Not an XMPMeta object" )
			xmpfile.close_file()
Exemple #10
0
 def test_close_file(self):
     for f, fmt in samplefiles.iteritems():
         xmpfile = XMPFiles(file_path=f)
         xmpfile.close_file()
Exemple #11
0
 def test_get_xmp(self):
     for f, fmt in samplefiles.iteritems():
         xmpfile = XMPFiles(file_path=f)
         xmp = xmpfile.get_xmp()
         self.assert_(isinstance(xmp, XMPMeta), "Not an XMPMeta object")
         xmpfile.close_file()
Exemple #12
0
 def test_file_to_dict(self):
     for f, fmt in samplefiles.iteritems():
         self.assert_(file_to_dict(f), "Expected dictionary")
Exemple #13
0
 def test_object_to_dict(self):
     for f, fmt in samplefiles.iteritems():
         xmpfile = XMPFiles(file_path=f)
         xmp = xmpfile.get_xmp()
         self.assert_(object_to_dict(xmp), "Not an XMPMeta object")
         xmpfile.close_file()