summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
64da09e)
The test checks for a pixel value after rotation (good
idea!). But the value seems to be a bit different on some
platforms, so use a list of seen values.
Not the perfect solution, but it works.
from mediagoblin.tools.exif import exif_fix_image_orientation, \
extract_exif, clean_exif, get_gps_data, get_useful
from mediagoblin.tools.exif import exif_fix_image_orientation, \
extract_exif, clean_exif, get_gps_data, get_useful
+
+def assert_in(a, b):
+ assert a in b, "%r not in %r" % (a, b)
+
+
GOOD_JPG = pkg_resources.resource_filename(
'mediagoblin.tests',
os.path.join(
GOOD_JPG = pkg_resources.resource_filename(
'mediagoblin.tests',
os.path.join(
'test_exif',
'has-gps.jpg'))
'test_exif',
'has-gps.jpg'))
def test_exif_extraction():
'''
Test EXIF extraction from a good image
def test_exif_extraction():
'''
Test EXIF extraction from a good image
32, 32, 32],
'field_length': 44}}
32, 32, 32],
'field_length': 44}}
def test_exif_image_orientation():
'''
Test image reorientation based on EXIF data
def test_exif_image_orientation():
'''
Test image reorientation based on EXIF data
assert image.size == (428, 640)
# If this pixel looks right, the rest of the image probably will too.
assert image.size == (428, 640)
# If this pixel looks right, the rest of the image probably will too.
- assert image.getdata()[10000] == (41, 28, 11)
+ assert_in(image.getdata()[10000],
+ ((41, 28, 11), (43, 27, 11))
+ )
+
def test_exif_no_exif():
'''
def test_exif_no_exif():
'''
assert gps == {}
assert useful == {}
assert gps == {}
assert useful == {}
def test_exif_bad_image():
'''
Test EXIF extraction from a faithful, but bad image
def test_exif_bad_image():
'''
Test EXIF extraction from a faithful, but bad image
assert gps == {}
assert useful == {}
assert gps == {}
assert useful == {}
def test_exif_gps_data():
'''
Test extractiion of GPS data
def test_exif_gps_data():
'''
Test extractiion of GPS data
'direction': 25.674046740467404,
'altitude': 37.64365671641791,
'longitude': 18.016166666666667}
'direction': 25.674046740467404,
'altitude': 37.64365671641791,
'longitude': 18.016166666666667}