gh-84 Added tests for invalid files with valid file extensions
This commit is contained in:
parent
47bd57d40d
commit
e35e0ce471
|
@ -30,9 +30,9 @@ class Media(object):
|
|||
__name__ = 'Media'
|
||||
|
||||
d_coordinates = {
|
||||
'latitude' : 'latitude_ref',
|
||||
'longitude': 'longitude_ref'
|
||||
}
|
||||
'latitude': 'latitude_ref',
|
||||
'longitude': 'longitude_ref'
|
||||
}
|
||||
|
||||
def __init__(self, source=None):
|
||||
self.source = source
|
||||
|
|
|
@ -78,9 +78,9 @@ class Photo(Media):
|
|||
# values for S and W
|
||||
coords = exif[key].value
|
||||
return geolocation.dms_to_decimal(
|
||||
*coords,
|
||||
direction = exif[self.exif_map[self.d_coordinates[type]]].value
|
||||
)
|
||||
*coords,
|
||||
direction=exif[self.exif_map[self.d_coordinates[type]]].value
|
||||
)
|
||||
|
||||
except KeyError:
|
||||
return None
|
||||
|
|
|
@ -181,6 +181,18 @@ def test_get_folder_path_with_location_and_title():
|
|||
|
||||
assert path == os.path.join('2015-12-Dec','Sunnyvale'), path
|
||||
|
||||
def test_process_file_invalid():
|
||||
filesystem = FileSystem()
|
||||
temporary_folder, folder = helper.create_working_folder()
|
||||
|
||||
origin = os.path.join(folder,'photo.jpg')
|
||||
shutil.copyfile(helper.get_file('invalid.jpg'), origin)
|
||||
|
||||
media = Photo(origin)
|
||||
destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)
|
||||
|
||||
assert destination is None
|
||||
|
||||
def test_process_file_plain():
|
||||
filesystem = FileSystem()
|
||||
temporary_folder, folder = helper.create_working_folder()
|
||||
|
|
|
@ -53,6 +53,12 @@ def test_is_not_valid():
|
|||
|
||||
assert not photo.is_valid()
|
||||
|
||||
def test_get_metadata_of_invalid_photo():
|
||||
photo = Photo(helper.get_file('invalid.jpg'))
|
||||
metadata = photo.get_metadata()
|
||||
|
||||
assert metadata is None
|
||||
|
||||
def test_get_coordinate_default():
|
||||
photo = Photo(helper.get_file('with-location.jpg'))
|
||||
coordinate = photo.get_coordinate()
|
||||
|
|
Loading…
Reference in New Issue