Exemplo n.º 1
0
    def test_write_update_tag_for_image(self):
        source = os.path.join(config.photo_dir, 'boris-1.jpg')
        temp_file = os.path.join(config.photo_dir, 'test_file.jpg')
        shutil.copyfile(source, temp_file)

        try:
            tags = {
                'comment': 'test comment',
                'keywords': 'test,keywords',
                'title': 'test title',
                'subject': 'test subject',
                'person_in_image': 'john doe,jill,john humpheries'
            }
            reader.update_exif('test_file.jpg', tags)

            retrieved_tags = reader.get_exif('test_file.jpg')
            self.assertDictContainsSubset(tags, retrieved_tags)
        finally:
            if (os.path.exists(temp_file)):
                os.remove(temp_file)
Exemplo n.º 2
0
    def test_write_update_tag_for_image(self):
        source = os.path.join(config.photo_dir, "boris-1.jpg")
        temp_file = os.path.join(config.photo_dir, "test_file.jpg")
        shutil.copyfile(source, temp_file)

        try:
            tags = {
                "comment": "test comment",
                "keywords": "test,keywords",
                "title": "test title",
                "subject": "test subject",
                "person_in_image": "john doe,jill,john humpheries",
            }
            reader.update_exif("test_file.jpg", tags)

            retrieved_tags = reader.get_exif("test_file.jpg")
            self.assertDictContainsSubset(tags, retrieved_tags)
        finally:
            if os.path.exists(temp_file):
                os.remove(temp_file)
Exemplo n.º 3
0
    def test_should_return_date(self):
        tags = reader.get_exif("IMG_3277.jpg", "date")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["date"], "2012-06-03T18:16:49")
Exemplo n.º 4
0
    def test_should_return_keywords(self):
        tags = reader.get_exif("IMG_3277.jpg", "keywords")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["keywords"], "keyword1,keyword2")
Exemplo n.º 5
0
    def test_should_fix_up_GPS_coordinates(self):
        tags = reader.get_exif("IMG_3277.jpg", "longitude,latitude")

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags["latitude"], 43.493369)
        self.assertEquals(tags["longitude"], -1.554734)
Exemplo n.º 6
0
    def test_tag_search_should_be_case_insensitive(self):
        tags = reader.get_exif("IMG_3277.jpg", "Make,moDel")

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags["make"], "Canon")
        self.assertEquals(tags["model"], "Canon EOS 550D")
Exemplo n.º 7
0
    def test_should_return_only_search_tags(self):
        tags = reader.get_exif("IMG_3277.jpg", "make,model")

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags["make"], "Canon")
        self.assertEquals(tags["model"], "Canon EOS 550D")
Exemplo n.º 8
0
 def test_should_return_all_tags(self):
     tags = reader.get_exif("IMG_3277.jpg")
     self.assertItemsEqual(tags.keys(), required_image_tags)
Exemplo n.º 9
0
    def test_should_return_blank_if_tag_not_found(self):
        tags = reader.get_exif("IMG_3277.jpg", "person_in_image")

        self.assertEquals(len(tags.keys()), 0)
Exemplo n.º 10
0
    def test_should_not_return_missing_search_tags(self):
        tags = reader.get_exif('IMG_3277.jpg', 'UNKNOWN_KEY')

        self.assertEquals(len(tags.keys()), 0)
Exemplo n.º 11
0
    def test_tag_search_should_be_case_insensitive(self):
        tags = reader.get_exif('IMG_3277.jpg', 'Make,moDel')

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags['make'], 'Canon')
        self.assertEquals(tags['model'], 'Canon EOS 550D')
Exemplo n.º 12
0
    def test_tag_search_should_handle_spaces_between_commas(self):
        tags = reader.get_exif('IMG_3277.jpg', '  make  ,  model  ')

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags['make'], 'Canon')
        self.assertEquals(tags['model'], 'Canon EOS 550D')
Exemplo n.º 13
0
    def test_should_return_only_search_tags(self):
        tags = reader.get_exif('IMG_3277.jpg', 'make,model')

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags['make'], 'Canon')
        self.assertEquals(tags['model'], 'Canon EOS 550D')
Exemplo n.º 14
0
 def test_should_return_all_tags_with_None_tag_parameter(self):
     tags = reader.get_exif('IMG_3277.jpg', None)
     self.assertItemsEqual(tags.keys(), required_image_tags)
Exemplo n.º 15
0
 def test_should_return_all_tags(self):
     tags = reader.get_exif('IMG_3277.jpg')
     self.assertItemsEqual(tags.keys(), required_image_tags)
Exemplo n.º 16
0
    def test_should_return_date3(self):
        tags = reader.get_exif("P9103882.jpg", "date")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["date"], "2012-09-10T10:30:00")
Exemplo n.º 17
0
    def test_should_return_blank_if_tag_not_found(self):
        tags = reader.get_exif('IMG_3277.jpg', 'person_in_image')

        self.assertEquals(len(tags.keys()), 0)
Exemplo n.º 18
0
    def test_should_fix_up_GPS_coordinates(self):
        tags = reader.get_exif('IMG_3277.jpg', 'longitude,latitude')

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags['latitude'], 43.493369)
        self.assertEquals(tags['longitude'], -1.554734)
Exemplo n.º 19
0
    def test_should_return_comment(self):
        tags = reader.get_exif('IMG_3277.jpg', 'comment')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['comment'], 'This is a comment')
Exemplo n.º 20
0
    def test_should_return_keywords(self):
        tags = reader.get_exif('IMG_3277.jpg', 'keywords')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['keywords'], 'keyword1,keyword2')
Exemplo n.º 21
0
 def test_should_return_all_tags_with_None_tag_parameter(self):
     tags = reader.get_exif("IMG_3277.jpg", None)
     self.assertItemsEqual(tags.keys(), required_image_tags)
Exemplo n.º 22
0
    def test_should_return_title(self):
        tags = reader.get_exif('IMG_3277.jpg', 'title')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['title'], 'Title goes here')
Exemplo n.º 23
0
    def test_tag_search_should_handle_spaces_between_commas(self):
        tags = reader.get_exif("IMG_3277.jpg", "  make  ,  model  ")

        self.assertEquals(len(tags.keys()), 2)
        self.assertEquals(tags["make"], "Canon")
        self.assertEquals(tags["model"], "Canon EOS 550D")
Exemplo n.º 24
0
    def test_should_return_date(self):
        tags = reader.get_exif('IMG_3277.jpg', 'date')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['date'], '2012-06-03T18:16:49')
Exemplo n.º 25
0
    def test_should_not_return_missing_search_tags(self):
        tags = reader.get_exif("IMG_3277.jpg", "UNKNOWN_KEY")

        self.assertEquals(len(tags.keys()), 0)
Exemplo n.º 26
0
    def test_should_return_date2(self):
        tags = reader.get_exif('wilderness-01.jpg', 'date')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['date'], '2009-01-09T08:50:41')
Exemplo n.º 27
0
    def test_should_return_comment(self):
        tags = reader.get_exif("IMG_3277.jpg", "comment")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["comment"], "This is a comment")
Exemplo n.º 28
0
    def test_should_return_date3(self):
        tags = reader.get_exif('P9103882.jpg', 'date')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['date'], '2012-09-10T10:30:00')
Exemplo n.º 29
0
    def test_should_return_title(self):
        tags = reader.get_exif("IMG_3277.jpg", "title")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["title"], "Title goes here")
Exemplo n.º 30
0
    def test_should_return_subject(self):
        tags = reader.get_exif('IMG_3277.jpg', 'subject')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['subject'], 'This is a subject')
Exemplo n.º 31
0
    def test_should_return_date2(self):
        tags = reader.get_exif("wilderness-01.jpg", "date")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["date"], "2009-01-09T08:50:41")
Exemplo n.º 32
0
    def test_should_return_person_in_image(self):
        tags = reader.get_exif("IMG_6868.jpg", "person_in_image")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["person_in_image"], "rachel,richard")
Exemplo n.º 33
0
    def test_should_return_subject(self):
        tags = reader.get_exif("IMG_3277.jpg", "subject")

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags["subject"], "This is a subject")
Exemplo n.º 34
0
    def test_should_return_person_in_image(self):
        tags = reader.get_exif('IMG_6868.jpg', 'person_in_image')

        self.assertEquals(len(tags.keys()), 1)
        self.assertEquals(tags['person_in_image'], 'rachel,richard')