~osomon/pyexiv2/pyexiv2-0.1.3

« back to all changes in this revision

Viewing changes to unittest/Bug183332_TestCase.py

  • Committer: Olivier Tilloy
  • Date: 2008-02-09 00:39:46 UTC
  • Revision ID: olivier@tilloy.net-20080209003946-xqi84jziix0ggp0j
Added a test to the unit test for bug #183332.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        image = pyexiv2.Image(filename)
57
57
        image.readMetadata()
58
58
        key = 'Exif.Image.Artist'
 
59
        self.assert_(key in image.exifKeys())
59
60
        value = 12
60
61
        # EXIF artist is a string, voluntarily pass an integer as argument
61
62
        image[key] = value
74
75
        image = pyexiv2.Image(filename)
75
76
        image.readMetadata()
76
77
        key = 'Iptc.Application2.Keywords'
 
78
        self.assert_(key in image.iptcKeys())
77
79
        values = (5, 6)
78
80
        # IPTC keywords are strings, voluntarily pass integers as arguments
79
81
        image[key] = values
80
82
        self.assertEqual(image[key], tuple([str(v) for v in values]))
81
83
 
 
84
    def testSetNotSetEXIFTagValue(self):
 
85
        """
 
86
        Test the value type of the internally cached metadata after setting an
 
87
        EXIF tag that was not previously set.
 
88
        """
 
89
        # Check that the reference file is not corrupted
 
90
        filename = os.path.join('data', 'smiley1.jpg')
 
91
        md5sum = 'c066958457c685853293058f9bf129c1'
 
92
        self.assert_(testutils.CheckFileSum(filename, md5sum))
 
93
 
 
94
        image = pyexiv2.Image(filename)
 
95
        image.readMetadata()
 
96
        key = 'Exif.Image.Model'
 
97
        self.assert_(key not in image.exifKeys())
 
98
        value = 34L
 
99
        # EXIF model is a string, voluntarily pass a long as argument
 
100
        image[key] = value
 
101
        self.assertEqual(image[key], str(value))
 
102