def test_all(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/selectdata.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) G = gpspixtrax.GPSPixTrax(imagedata) G.parse() for slice in imagedata: K = kml.KMLPaths(slice) k = K.KMLPath('foo', kml.MODE.valid) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.validated) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.gps) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.projected) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.interpolated) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.valid & kml.MODE.projected) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.valid & kml.MODE.interpolated) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.gps & kml.MODE.projected) self.assert_no_repeats(k) k = K.KMLPath('foo', kml.MODE.gps & kml.MODE.interpolated) self.assert_no_repeats(k) k = K.KMLPaths('foo') self.assert_no_repeats(k)
def test_parse_process(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/selectdata.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) # 12 subdirectories for 12 days self.assertEquals(len(imagedata), 12) # images sorted within the slices G = gpspixtrax.GPSPixTrax(imagedata) for tag in ('gpstime', 'localtime', 'pseudolocaltime', 'tzoffset', 'tzseconds'): self.assertEqual(set(tag in i for i in imagedata), set((False,))) I.assert_called_once_with(filelist) G.parsetime() for slice in imagedata: for tag in ('gpstime', 'localtime', 'pseudolocaltime'): self.assertEqual(set(tag in i for i in slice), set((True,))) for tag in ('tzoffset', 'tzseconds'): self.assertEqual( set(tag in i for i in slice if i.GPSStatus == 'A'), set((True,))) self.assertEqual( set(tag in i for i in slice if i.GPSStatus == 'V'), set((False,))) G.sortslices() for slice in imagedata: filenames = [os.path.basename(x.SourceFile) for x in slice] self.assertEquals(filenames, sorted(filenames)) G.pass2() G.pass3() self.assertNoHalfHourTimezone(imagedata)
def test_parse_end_inactive(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/initialoffset.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) G = gpspixtrax.GPSPixTrax(imagedata) G.parsetime() for tag in ('tzoffset', 'tzseconds'): # one has tz info, the others do not self.assertEqual(set(tag in i for i in imagedata[0]), set((False, True))) G.sortslices() G.pass2() for tag in ('tzoffset', 'tzseconds'): # tz info has been copied from the one known good image self.assertEqual(set(tag in i for i in imagedata[0]), set((True,)))
def test_parse_disjoint_clocks(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/disjointclockinvalid.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) G = gpspixtrax.GPSPixTrax(imagedata) G.parsetime() for tag in ('tzoffset', 'tzseconds'): self.assertEqual(tag in imagedata[0][0], False) G.sortslices() G.pass2() for tag in ('tzoffset', 'tzseconds'): self.assertEqual(tag in imagedata[0][0], False) G.pass3() for tag in ('tzoffset', 'tzseconds', 'gpsStampAge'): # localtime and gps time not close enough together to guess self.assertEqual(tag in imagedata[0][0], False) self.assertNoHalfHourTimezone(imagedata)
def test_parse_too_far_apart(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/farapart.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) # hack the data to have the same timestamp but incomparable filenames that would # sort if they were comparable (had the same three-character prefix) imagedata[0][1].GPSDateTime = imagedata[0][0].GPSDateTime imagedata[0][1].SourceFile = imagedata[0][0].SourceFile.replace('dsc04', 'img03') G = gpspixtrax.GPSPixTrax(imagedata) G.parsetime() self.assertEquals(imagedata[0][0].SourceFile[0:5], 'dsc04') self.assertEquals(imagedata[0][1].SourceFile[0:5], 'img03') G.sortslices() # didn't change self.assertEquals(imagedata[0][0].SourceFile[0:5], 'dsc04') self.assertEquals(imagedata[0][1].SourceFile[0:5], 'img03') imagedata[0][1].SourceFile = imagedata[0][0].SourceFile.replace('dsc', 'img')
def test_parse_no_active(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/nooffset.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) G = gpspixtrax.GPSPixTrax(imagedata) G.parsetime() for tag in ('tzoffset', 'tzseconds'): # no valid GPS stamps, so nothing to trust yet self.assertEqual(set(tag in i for i in imagedata[0]), set((False,))) G.sortslices() G.pass2() for tag in ('tzoffset', 'tzseconds'): # no valid GPS stamps to copy, so nothing to trust yet self.assertEqual(set(tag in i for i in imagedata[0]), set((False,))) G.pass3() for tag in ('tzoffset', 'tzseconds', 'gpsStampAge'): # now that we know no valid GPS stamps nearby, just guess self.assertEqual(set(tag in i for i in imagedata[0]), set((True,))) self.assertNoHalfHourTimezone(imagedata)
def test_parse_too_far_apart(self, I): directory = os.path.dirname(__file__) I.return_value = xz( '-d', '-c', directory + '/data/farapart.json.xz') filelist = mock.Mock() imagedata = exiftool.fetchdata(filelist) G = gpspixtrax.GPSPixTrax(imagedata) G.parsetime() for tag in ('tzoffset', 'tzseconds'): # one has tz info, the others do not self.assertEqual(set(tag in i for i in imagedata[0]), set((False, True))) G.sortslices() G.pass2() for tag in ('tzoffset', 'tzseconds'): # GPS stamp too far away to trust self.assertEqual(set(tag in i for i in imagedata[0]), set((False, True))) G.pass3() for tag in ('tzoffset', 'tzseconds'): # localtime and gps time close enough together to guess self.assertEqual(set(tag in i for i in imagedata[0]), set((True,))) self.assertNoHalfHourTimezone(imagedata)
def test_fetchdata(self, I): I.return_value = '''[{ "SourceFile": "1/dsc05521_arw.jpg", "GPSDateTime": "2013:06:11 17:31:10.577Z", "GPSAltitude": 11.4, "GPSLatitude": 70.0833613888889, "GPSLongitude": 16.0796983333333, "GPSSpeed": 36.2, "GPSStatus": "V", "GPSTrack": 52.74, "GPSMeasureMode": 3, "DateTimeOriginal": "2013:06:12 07:27:01", "ShotNumberSincePowerUp": 1 }, { "SourceFile": "1/dsc05870_arw.jpg", "GPSDateTime": "2013:06:12 13:49:52Z", "GPSAltitude": -0.6, "GPSLatitude": 70.984505, "GPSLongitude": 25.9636263888889, "GPSSpeed": 1.7, "GPSStatus": "V", "GPSTrack": 325.31, "GPSMeasureMode": 3, "DateTimeOriginal": "2013:06:12 20:29:38", "ShotNumberSincePowerUp": 198 }, { "SourceFile": "2/dsc08142.jpg", "GPSDateTime": "2013:06:18 06:36:57.463Z", "GPSAltitude": 93.9, "GPSLatitude": 58.1362883333333, "GPSLongitude": 7.99556972222222, "GPSSpeed": 0.8, "GPSStatus": "A", "GPSTrack": 130.03, "GPSMeasureMode": 3, "DateTimeOriginal": "2013:06:18 08:37:01", "ShotNumberSincePowerUp": 1 }] ''' i = exiftool.fetchdata(['1/dsc05521_arw.jpg', '1/dsc05870_arw.jpg', '2/dsc08142.jpg']) self.assertEquals(len(i), 2) self.assertEquals(len(i[0]), 2) self.assertEquals(len(i[1]), 1) self.assertEquals(isinstance(i[0][0], ddict.ddict), True) I.assert_called('-n', '-j', '-GPSDateTime', '-GPSAltitude', '-GPSLatitude', '-GPSLongitude', '-GPSSpeed', '-GPSStatus', '-GPSTrack', '-GPSMeasureMode', '-DateTimeOriginal', '-ShotNumberSincePowerUp', 'dsc05521_arw.jpg', 'dsc05870_arw.jpg', 'dsc08142.jpg')