Add unit test for #5524
Add a unit test to verify that the change introduced in 07c535c no longer resulst in a zero divide error when gps data contains no divisor. This commit includes a test image created by Andrew Browning. Andrew Browning dedicates this image to the public domain under the CC0 license.
This commit is contained in:
parent
07c535c876
commit
66dbc22e73
@ -41,3 +41,4 @@ GOOD_JPG = resource_exif('good.jpg')
|
|||||||
EMPTY_JPG = resource_exif('empty.jpg')
|
EMPTY_JPG = resource_exif('empty.jpg')
|
||||||
BAD_JPG = resource_exif('bad.jpg')
|
BAD_JPG = resource_exif('bad.jpg')
|
||||||
GPS_JPG = resource_exif('has-gps.jpg')
|
GPS_JPG = resource_exif('has-gps.jpg')
|
||||||
|
BAD_GPS_JPG = resource_exif('bad-gps.jpg')
|
||||||
|
@ -24,7 +24,7 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
from mediagoblin.tools.exif import exif_fix_image_orientation, \
|
from mediagoblin.tools.exif import exif_fix_image_orientation, \
|
||||||
extract_exif, clean_exif, get_gps_data, get_useful
|
extract_exif, clean_exif, get_gps_data, get_useful
|
||||||
from .resources import GOOD_JPG, EMPTY_JPG, BAD_JPG, GPS_JPG
|
from .resources import GOOD_JPG, EMPTY_JPG, BAD_JPG, GPS_JPG, BAD_GPS_JPG
|
||||||
|
|
||||||
|
|
||||||
def assert_in(a, b):
|
def assert_in(a, b):
|
||||||
@ -437,3 +437,18 @@ def test_exif_gps_data():
|
|||||||
'direction': 25.674046740467404,
|
'direction': 25.674046740467404,
|
||||||
'altitude': 37.64365671641791,
|
'altitude': 37.64365671641791,
|
||||||
'longitude': 18.016166666666667}
|
'longitude': 18.016166666666667}
|
||||||
|
|
||||||
|
|
||||||
|
def test_exif_bad_gps_data():
|
||||||
|
'''
|
||||||
|
Test extraction of GPS data from an image with bad GPS data
|
||||||
|
'''
|
||||||
|
result = extract_exif(BAD_GPS_JPG)
|
||||||
|
gps = get_gps_data(result)
|
||||||
|
print(gps)
|
||||||
|
|
||||||
|
assert gps == {
|
||||||
|
'latitude': 0.0,
|
||||||
|
'direction': 0.0,
|
||||||
|
'altitude': 0.0,
|
||||||
|
'longitude': 0.0}
|
||||||
|
BIN
mediagoblin/tests/test_exif/bad-gps.jpg
Normal file
BIN
mediagoblin/tests/test_exif/bad-gps.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 138 KiB |
Loading…
x
Reference in New Issue
Block a user