diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-04-06 09:32:45 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-04-06 09:32:45 +0200 |
commit | 20a7f1bfefcacdf1789e7b5cf5183103702ce76c (patch) | |
tree | 213e92d36c5710d61b3d84e37ae2a6c9f25eda59 | |
parent | 1e31b92827c0e01393c7b9439a395c2ee0a90c6d (diff) | |
download | pyexiv2-20a7f1bfefcacdf1789e7b5cf5183103702ce76c.tar.gz |
Prepared unit tests methods for implementation completeness.
-rw-r--r-- | src/pyexiv2.py | 38 | ||||
-rw-r--r-- | unittest/metadata.py | 92 |
2 files changed, 130 insertions, 0 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index b70cc65..1aec66f 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -1098,9 +1098,39 @@ class ImageMetadata(object): tag.metadata = self def _set_iptc_tag_values(self, key, values): + # Overwrite the tag value for an already existing tag. + # The tag is already in cache. + # Warning: this is not meant to be called directly as it doesn't update + # the internal cache (which would leave the object in an inconsistent + # state). + # TODO + raise NotImplementedError() + + def _set_xmp_tag(self, tag): + # TODO + raise NotImplementedError() + + def _set_xmp_tag_values(self, key, values): + # Overwrite the tag value for an already existing tag. + # The tag is already in cache. + # Warning: this is not meant to be called directly as it doesn't update + # the internal cache (which would leave the object in an inconsistent + # state). # TODO raise NotImplementedError() + def __setitem__(self, key, tag): + """ + Set a metadata tag for a given key. + Override existing values. + DOCME. + """ + family = key.split('.')[0].lower() + try: + return getattr(self, '_set_%s_tag' % family)(key, tag) + except AttributeError: + raise KeyError(key) + def _delete_exif_tag(self, key): if key not in self.exif_keys: raise KeyError('Cannot delete an inexistent tag') @@ -1115,6 +1145,14 @@ class ImageMetadata(object): # TODO raise NotImplementedError() + def _delete_xmp_tag(self, key): + # TODO + raise NotImplementedError() + + def __delitem__(self, key): + # TODO + raise NotImplementedError() + class Image(libexiv2python.Image): diff --git a/unittest/metadata.py b/unittest/metadata.py index 4512350..abc6770 100644 --- a/unittest/metadata.py +++ b/unittest/metadata.py @@ -130,6 +130,10 @@ class TestImageMetadata(unittest.TestCase): ['uuid:9A3B7F52214211DAB6308A7391270C13']) self.metadata._image.tags['xmp'] = tags + ###################### + # Test general methods + ###################### + def test_read(self): self.assertEqual(self.metadata._image, None) self.metadata.read() @@ -142,6 +146,10 @@ class TestImageMetadata(unittest.TestCase): self.metadata.write() self.failUnless(self.metadata._image.written) + ########################### + # Test EXIF-related methods + ########################### + def test_exif_keys(self): self.metadata.read() self._set_exif_tags() @@ -277,6 +285,10 @@ class TestImageMetadata(unittest.TestCase): self.assertEqual(self.metadata._tags['exif'], {}) self.failIf(self.metadata._image.tags['exif'].has_key(key)) + ########################### + # Test IPTC-related methods + ########################### + def test_iptc_keys(self): self.metadata.read() self._set_iptc_tags() @@ -360,6 +372,34 @@ class TestImageMetadata(unittest.TestCase): self.assertEqual(self.metadata._image.tags['iptc'][key], new_tag.raw_value) + def test_set_iptc_tag_value_inexistent(self): + # TODO + raise(NotImplementedError()) + + def test_set_iptc_tag_value_wrong_type(self): + # TODO + raise(NotImplementedError()) + + def test_set_iptc_tag_value(self): + # TODO + raise(NotImplementedError()) + + def test_delete_iptc_tag_inexistent(self): + # TODO + raise(NotImplementedError()) + + def test_delete_iptc_tag_not_cached(self): + # TODO + raise(NotImplementedError()) + + def test_delete_iptc_tag_cached(self): + # TODO + raise(NotImplementedError()) + + ########################## + # Test XMP-related methods + ########################## + def test_xmp_keys(self): self.metadata.read() self._set_xmp_tags() @@ -382,6 +422,50 @@ class TestImageMetadata(unittest.TestCase): key = 'Xmp.xmp.Label' self.failUnlessRaises(KeyError, self.metadata._get_xmp_tag, key) + def test_set_xmp_tag_wrong(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_create(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_overwrite(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_overwrite_already_cached(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_value_inexistent(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_value_wrong_type(self): + # TODO + raise(NotImplementedError()) + + def test_set_xmp_tag_value(self): + # TODO + raise(NotImplementedError()) + + def test_delete_xmp_tag_inexistent(self): + # TODO + raise(NotImplementedError()) + + def test_delete_xmp_tag_not_cached(self): + # TODO + raise(NotImplementedError()) + + def test_delete_xmp_tag_cached(self): + # TODO + raise(NotImplementedError()) + + ########################### + # Test dictionary interface + ########################### + def test_getitem(self): self.metadata.read() self._set_exif_tags() @@ -402,3 +486,11 @@ class TestImageMetadata(unittest.TestCase): 'Xmp.xmp.Rating', 'Wrong.Noluck.Raise') for key in keys: self.failUnlessRaises(KeyError, self.metadata.__getitem__, key) + + def test_setitem(self): + # TODO + raise(NotImplementedError()) + + def test_delitem(self): + # TODO + raise(NotImplementedError()) |