gh-31 Remove raise SkipTest for geolocation tests due to precision loss
This commit is contained in:
parent
f234cb989d
commit
a66fc7ca41
|
@ -27,7 +27,7 @@ class Photo(Media):
|
||||||
__name__ = 'Photo'
|
__name__ = 'Photo'
|
||||||
|
|
||||||
#: Valid extensions for photo files.
|
#: Valid extensions for photo files.
|
||||||
extensions = ('jpg', 'jpeg', 'nef', 'dng', 'gif')
|
extensions = ('nef', 'dng', 'gif', 'jpg', 'jpeg')
|
||||||
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
super(Photo, self).__init__(source)
|
super(Photo, self).__init__(source)
|
||||||
|
|
|
@ -118,6 +118,9 @@ def time_convert(s_time):
|
||||||
# with relative tolerance c
|
# with relative tolerance c
|
||||||
|
|
||||||
def isclose(a, b, rel_tol = 1e-8):
|
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)
|
diff = abs(a - b)
|
||||||
return (diff <= abs(rel_tol * a) and
|
return (diff <= abs(rel_tol * a) and
|
||||||
diff <= abs(rel_tol * b))
|
diff <= abs(rel_tol * b))
|
||||||
|
|
|
@ -102,7 +102,6 @@ def test_set_location():
|
||||||
if not can_edit_exif():
|
if not can_edit_exif():
|
||||||
raise SkipTest('avmetareadwrite executable not found')
|
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()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/audio.m4a' % folder
|
origin = '%s/audio.m4a' % folder
|
||||||
|
@ -111,9 +110,10 @@ def test_set_location():
|
||||||
audio = Audio(origin)
|
audio = Audio(origin)
|
||||||
origin_metadata = audio.get_metadata()
|
origin_metadata = audio.get_metadata()
|
||||||
|
|
||||||
# Verify that original photo has no location information
|
# Verify that original audio has different location info that what we
|
||||||
#assert origin_metadata['latitude'] is None, origin_metadata['latitude']
|
# will be setting and checking
|
||||||
#assert origin_metadata['longitude'] is None, origin_metadata['longitude']
|
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)
|
status = audio.set_location(11.1111111111, 99.9999999999)
|
||||||
|
|
||||||
|
@ -124,9 +124,8 @@ def test_set_location():
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
# @TODO: understand why the decimal to degree conversion loses accuracy
|
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
|
||||||
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
|
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
|
||||||
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
|
|
||||||
|
|
||||||
def test_set_title():
|
def test_set_title():
|
||||||
if not can_edit_exif():
|
if not can_edit_exif():
|
||||||
|
|
|
@ -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']
|
assert date_taken == helper.time_convert((2013, 9, 30, 7, 6, 5, 0, 273, 0)), metadata['date_taken']
|
||||||
|
|
||||||
def test_set_location():
|
def test_set_location():
|
||||||
raise SkipTest('gh-31, precision is lost in conversion from decimal to dms')
|
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/photo.jpg' % folder
|
origin = '%s/photo.jpg' % folder
|
||||||
|
@ -177,9 +176,10 @@ def test_set_location():
|
||||||
photo = Photo(origin)
|
photo = Photo(origin)
|
||||||
origin_metadata = photo.get_metadata()
|
origin_metadata = photo.get_metadata()
|
||||||
|
|
||||||
# Verify that original photo has no location information
|
# Verify that original photo has different location info that what we
|
||||||
assert origin_metadata['latitude'] is None, origin_metadata['latitude']
|
# will be setting and checking
|
||||||
assert origin_metadata['longitude'] is None, origin_metadata['longitude']
|
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)
|
status = photo.set_location(11.1111111111, 99.9999999999)
|
||||||
|
|
||||||
|
@ -190,9 +190,8 @@ def test_set_location():
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
# @TODO: understand why the decimal to degree conversion loses accuracy
|
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
|
||||||
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
|
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
|
||||||
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
|
|
||||||
|
|
||||||
def test_set_title():
|
def test_set_title():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
|
@ -101,7 +101,6 @@ def test_set_location():
|
||||||
if not can_edit_exif():
|
if not can_edit_exif():
|
||||||
raise SkipTest('avmetareadwrite executable not found')
|
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()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/video.mov' % folder
|
origin = '%s/video.mov' % folder
|
||||||
|
@ -110,9 +109,10 @@ def test_set_location():
|
||||||
video = Video(origin)
|
video = Video(origin)
|
||||||
origin_metadata = video.get_metadata()
|
origin_metadata = video.get_metadata()
|
||||||
|
|
||||||
# Verify that original photo has no location information
|
# Verify that original video has different location info that what we
|
||||||
#assert origin_metadata['latitude'] is None, origin_metadata['latitude']
|
# will be setting and checking
|
||||||
#assert origin_metadata['longitude'] is None, origin_metadata['longitude']
|
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)
|
status = video.set_location(11.1111111111, 99.9999999999)
|
||||||
|
|
||||||
|
@ -123,9 +123,8 @@ def test_set_location():
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
# @TODO: understand why the decimal to degree conversion loses accuracy
|
assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude']
|
||||||
assert metadata['latitude'] == 11.1111111111, metadata['latitude']
|
assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
|
||||||
assert metadata['longitude'] == 99.9999999999, metadata['longitude']
|
|
||||||
|
|
||||||
def test_set_title():
|
def test_set_title():
|
||||||
if not can_edit_exif():
|
if not can_edit_exif():
|
||||||
|
|
Loading…
Reference in New Issue