gh-84 Added tests for invalid files with valid file extensions

This commit is contained in:
Jaisen Mathai 2016-02-14 00:55:39 -08:00
parent 47bd57d40d
commit e35e0ce471
5 changed files with 24 additions and 6 deletions

View File

@ -30,7 +30,7 @@ class Media(object):
__name__ = 'Media' __name__ = 'Media'
d_coordinates = { d_coordinates = {
'latitude' : 'latitude_ref', 'latitude': 'latitude_ref',
'longitude': 'longitude_ref' 'longitude': 'longitude_ref'
} }

View File

@ -79,7 +79,7 @@ class Photo(Media):
coords = exif[key].value coords = exif[key].value
return geolocation.dms_to_decimal( return geolocation.dms_to_decimal(
*coords, *coords,
direction = exif[self.exif_map[self.d_coordinates[type]]].value direction=exif[self.exif_map[self.d_coordinates[type]]].value
) )
except KeyError: except KeyError:

View File

View File

@ -181,6 +181,18 @@ def test_get_folder_path_with_location_and_title():
assert path == os.path.join('2015-12-Dec','Sunnyvale'), path 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(): def test_process_file_plain():
filesystem = FileSystem() filesystem = FileSystem()
temporary_folder, folder = helper.create_working_folder() temporary_folder, folder = helper.create_working_folder()

View File

@ -53,6 +53,12 @@ def test_is_not_valid():
assert not photo.is_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(): def test_get_coordinate_default():
photo = Photo(helper.get_file('with-location.jpg')) photo = Photo(helper.get_file('with-location.jpg'))
coordinate = photo.get_coordinate() coordinate = photo.get_coordinate()