예제 #1
0
    def test_get_exception_handles(self):
        """
        Unit Test: trigger exceptions list in get_exif_datetime()
        """
        result = exif_tool.get_exif_datetime('gym_drink_ad.jpg')
        self.assertEqual(result, 'create stamp not found:')

        result = exif_tool.get_exif_datetime('null_file.jpg')
        self.assertEqual(result, 'File does not exist!!')

        result = exif_tool.get_exif_datetime('text.txt')
        self.assertEqual(result[:11], 'Skipped!!: ')
예제 #2
0
    def test_set__good_bad_files(self):
        """
        include some bad files in list of files to set, non_image, nonexistent file
        bad files and good files are order independent
        on good files, set dates, integration test alters datetime, and get_exif_datetime confirms good files processed
        """
        current_year = datetime.now().year
        exif_tool.set_exif_datetime('tcook.jpg', current_year, 10, 19, 0, 0, 0)
        exif_tool.set_exif_datetime('f18.jpg', current_year, 10, 19, 0, 0, 0)

        result = exif_tool.main(['-t', '10211423', 'text.txt', 'tcook.jpg',
                                 'none', 'f18.jpg'])
        self.assertEqual(result, 2)

        result = exif_tool.get_exif_datetime('tcook.jpg')
        self.assertEqual(result, str(current_year) + ':10:21 14:23:00')
        result = exif_tool.get_exif_datetime('f18.jpg')
        self.assertEqual(result, str(current_year) + ':10:21 14:23:00')
예제 #3
0
 def test_set_one_ccyy_sec(self):
     """
     Integration Test:
     test set-time format CCYYmmddHHMM.SS from options [[CC]YY]mmddHHMM[.SS]
     main() parses full datetime arg, runs set_exif_datetime(), compares get_exif_datetime()
     """
     exif_tool.main(['--set', '201710211423.02', 'oxygen_mag.jpg'])
     result = exif_tool.get_exif_datetime('oxygen_mag.jpg')
     self.assertEqual(result, '2017:10:21 14:23:02')
예제 #4
0
 def test_set_one_current_sec(self):
     """
     test set-time format mmddHHMM.SS from options [[CC]YY]mmddHHMM[.SS]
     check listing results match set arg
     """
     exif_tool.main(['-t', '10211423.13', 'oxygen_mag.jpg'])
     result = exif_tool.get_exif_datetime('oxygen_mag.jpg')
     current_year = str(datetime.now().year)
     self.assertEqual(result, current_year + ':10:21 14:23:13')
예제 #5
0
    def test_set_jpg(self):
        """
        Unit Test: set a new date & time with set_exif_datetime() and confirm with get_exif_datetime()
        """
        result = exif_tool.set_exif_datetime('299352.jpg', 2016, 5, 15, 16, 0,
                                             5)
        self.assertEqual(result, 0)

        result = exif_tool.get_exif_datetime('299352.jpg')
        self.assertEqual(result, '2016:05:15 16:00:05')
예제 #6
0
    def test_set_multiple_yy_nosec(self):
        """
        Integration Test:
        test set-time format YYmmddHHMM from options [[CC]YY]mmddHHMM[.SS]
        main() parses datetime arg without [CC] or [.SS] on [file]..[file],
        runs set_exif_datetime(), compares get_exif_datetime() on each [file] [file]
        """
        exif_tool.main(['-t', '1810120101',
                        'oxygen_mag.jpg',
                        'f18.jpg'])

        current_cc = round(datetime.now().year/100)
        current_yr = str(current_cc) + '18'

        result = exif_tool.get_exif_datetime('oxygen_mag.jpg')
        # self.assertEqual(result, '2018:10:12 01:01:00')
        self.assertEqual(result, current_yr + ':10:12 01:01:00')

        result = exif_tool.get_exif_datetime('f18.jpg')
        self.assertEqual(result, current_yr + ':10:12 01:01:00')
예제 #7
0
 def test_get_exif(self):
     """
     Unit Test: get_exif_datetime() on known file origin date & time
     """
     result = exif_tool.get_exif_datetime('jelena_dokic.jpg')
     self.assertEqual(result, '2002:05:29 13:04:29')