gh-31 Remove raise SkipTest for geolocation tests due to precision loss

This commit is contained in:
Jaisen Mathai 2016-03-23 09:34:35 -07:00
parent f234cb989d
commit a66fc7ca41
5 changed files with 22 additions and 22 deletions

View File

@ -27,7 +27,7 @@ class Photo(Media):
__name__ = 'Photo'
#: Valid extensions for photo files.
extensions = ('jpg', 'jpeg', 'nef', 'dng', 'gif')
extensions = ('nef', 'dng', 'gif', 'jpg', 'jpeg')
def __init__(self, source=None):
super(Photo, self).__init__(source)

View File

@ -118,6 +118,9 @@ def time_convert(s_time):
# with relative tolerance c
def isclose(a, b, rel_tol = 1e-8):
if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
return False
diff = abs(a - b)
return (diff <= abs(rel_tol * a) and
diff <= abs(rel_tol * b))

View File

@ -102,7 +102,6 @@ def test_set_location():
if not can_edit_exif():
raise SkipTest('avmetareadwrite executable not found')
raise SkipTest('gh-31, precision is lost in conversion from decimal to dms')
temporary_folder, folder = helper.create_working_folder()
origin = '%s/audio.m4a' % folder
@ -111,9 +110,10 @@ def test_set_location():
audio = Audio(origin)
origin_metadata = audio.get_metadata()
# Verify that original photo has no location information
#assert origin_metadata['latitude'] is None, origin_metadata['latitude']
#assert origin_metadata['longitude'] is None, origin_metadata['longitude']
# Verify that original audio has different location info that what we
# will be setting and checking
assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude']
assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude']
status = audio.set_location(11.1111111111, 99.9999999999)
@ -124,9 +124,8 @@ def test_set_location():
shutil.rmtree(folder)
# @TODO: understand why the decimal to degree conversion loses accuracy
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_set_title():
if not can_edit_exif():

View File

@ -168,7 +168,6 @@ def test_set_date_taken():
assert date_taken == helper.time_convert((2013, 9, 30, 7, 6, 5, 0, 273, 0)), metadata['date_taken']
def test_set_location():
raise SkipTest('gh-31, precision is lost in conversion from decimal to dms')
temporary_folder, folder = helper.create_working_folder()
origin = '%s/photo.jpg' % folder
@ -177,9 +176,10 @@ def test_set_location():
photo = Photo(origin)
origin_metadata = photo.get_metadata()
# Verify that original photo has no location information
assert origin_metadata['latitude'] is None, origin_metadata['latitude']
assert origin_metadata['longitude'] is None, origin_metadata['longitude']
# Verify that original photo has different location info that what we
# will be setting and checking
assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude']
assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude']
status = photo.set_location(11.1111111111, 99.9999999999)
@ -190,9 +190,8 @@ def test_set_location():
shutil.rmtree(folder)
# @TODO: understand why the decimal to degree conversion loses accuracy
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_set_title():
temporary_folder, folder = helper.create_working_folder()

View File

@ -101,7 +101,6 @@ def test_set_location():
if not can_edit_exif():
raise SkipTest('avmetareadwrite executable not found')
raise SkipTest('gh-31, precision is lost in conversion from decimal to dms')
temporary_folder, folder = helper.create_working_folder()
origin = '%s/video.mov' % folder
@ -110,9 +109,10 @@ def test_set_location():
video = Video(origin)
origin_metadata = video.get_metadata()
# Verify that original photo has no location information
#assert origin_metadata['latitude'] is None, origin_metadata['latitude']
#assert origin_metadata['longitude'] is None, origin_metadata['longitude']
# Verify that original video has different location info that what we
# will be setting and checking
assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude']
assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude']
status = video.set_location(11.1111111111, 99.9999999999)
@ -123,9 +123,8 @@ def test_set_location():
shutil.rmtree(folder)
# @TODO: understand why the decimal to degree conversion loses accuracy
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_set_title():
if not can_edit_exif():