Fix tests
This commit is contained in:
parent
5e026e68ee
commit
df0bf3c28e
|
@ -300,6 +300,7 @@ def _update(album, location, time, title, paths, debug):
|
||||||
media.set_album(album)
|
media.set_album(album)
|
||||||
updated = True
|
updated = True
|
||||||
|
|
||||||
|
import ipdb; ipdb.set_trace()
|
||||||
# Updating a title can be problematic when doing it 2+ times on a file.
|
# Updating a title can be problematic when doing it 2+ times on a file.
|
||||||
# You would end up with img_001.jpg -> img_001-first-title.jpg ->
|
# You would end up with img_001.jpg -> img_001-first-title.jpg ->
|
||||||
# img_001-first-title-second-title.jpg.
|
# img_001-first-title-second-title.jpg.
|
||||||
|
|
|
@ -483,6 +483,7 @@ class FileSystem(object):
|
||||||
# If Directory is in the config we assume full_path and its
|
# If Directory is in the config we assume full_path and its
|
||||||
# corresponding values (date, location) are also present
|
# corresponding values (date, location) are also present
|
||||||
config_directory = self.default_folder_path_definition
|
config_directory = self.default_folder_path_definition
|
||||||
|
config = load_config(constants.CONFIG_FILE)
|
||||||
if('Directory' in config):
|
if('Directory' in config):
|
||||||
config_directory = config['Directory']
|
config_directory = config['Directory']
|
||||||
# Get date mask from config
|
# Get date mask from config
|
||||||
|
|
|
@ -27,7 +27,11 @@ class Base(object):
|
||||||
|
|
||||||
__name__ = 'Base'
|
__name__ = 'Base'
|
||||||
|
|
||||||
extensions = ()
|
PHOTO = ('arw', 'cr2', 'dng', 'gif', 'heic', 'jpeg', 'jpg', 'nef', 'png', 'rw2')
|
||||||
|
AUDIO = ('m4a',)
|
||||||
|
VIDEO = ('avi', 'm4v', 'mov', 'mp4', 'mpg', 'mpeg', '3gp', 'mts')
|
||||||
|
|
||||||
|
extensions = PHOTO + AUDIO + VIDEO
|
||||||
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
self.source = source
|
self.source = source
|
||||||
|
@ -176,7 +180,9 @@ class Base(object):
|
||||||
if(len(folder) == 0):
|
if(len(folder) == 0):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.set_album(folder)
|
status = self.set_album(folder)
|
||||||
|
if status == False:
|
||||||
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def set_metadata_basename(self, new_basename):
|
def set_metadata_basename(self, new_basename):
|
||||||
|
|
|
@ -37,8 +37,8 @@ class Media(Base):
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
super(Media, self).__init__(source)
|
super(Media, self).__init__(source)
|
||||||
self.date_original = ['EXIF:DateTimeOriginal']
|
self.date_original = ['EXIF:DateTimeOriginal']
|
||||||
self.date_created = ['EXIF:CreateDate']
|
self.date_created = ['EXIF:CreateDate', 'QuickTime:CreateDate']
|
||||||
self.date_modified = ['File:FileModifyDate']
|
self.date_modified = ['File:FileModifyDate', 'QuickTime:ModifyDate']
|
||||||
self.camera_make_keys = ['EXIF:Make', 'QuickTime:Make']
|
self.camera_make_keys = ['EXIF:Make', 'QuickTime:Make']
|
||||||
self.camera_model_keys = ['EXIF:Model', 'QuickTime:Model']
|
self.camera_model_keys = ['EXIF:Model', 'QuickTime:Model']
|
||||||
self.album_keys = ['XMP-xmpDM:Album', 'XMP:Album']
|
self.album_keys = ['XMP-xmpDM:Album', 'XMP:Album']
|
||||||
|
@ -278,6 +278,12 @@ class Media(Base):
|
||||||
tags[key] = formatted_time
|
tags[key] = formatted_time
|
||||||
|
|
||||||
status = self.__set_tags(tags)
|
status = self.__set_tags(tags)
|
||||||
|
if status == False:
|
||||||
|
# exif attribute date_original d'ont exist
|
||||||
|
for key in self.date_created:
|
||||||
|
tags[key] = formatted_time
|
||||||
|
|
||||||
|
status = self.__set_tags(tags)
|
||||||
self.reset_cache()
|
self.reset_cache()
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
@ -356,5 +362,9 @@ class Media(Base):
|
||||||
|
|
||||||
status = ''
|
status = ''
|
||||||
status = ExifTool().set_tags(tags,source)
|
status = ExifTool().set_tags(tags,source)
|
||||||
|
if status.decode().find('unchanged') != -1 or status == '':
|
||||||
|
return False
|
||||||
|
if status.decode().find('error') != -1:
|
||||||
|
return False
|
||||||
|
|
||||||
return status != ''
|
return True
|
||||||
|
|
|
@ -34,7 +34,8 @@ class Video(Media):
|
||||||
super(Video, self).__init__(source)
|
super(Video, self).__init__(source)
|
||||||
self.date_original = [
|
self.date_original = [
|
||||||
'EXIF:DateTimeOriginal',
|
'EXIF:DateTimeOriginal',
|
||||||
'H264:DateTimeOriginal'
|
'H264:DateTimeOriginal',
|
||||||
|
'QuickTime:ContentCreateDate'
|
||||||
]
|
]
|
||||||
self.date_created = [
|
self.date_created = [
|
||||||
'EXIF:CreateDate',
|
'EXIF:CreateDate',
|
||||||
|
|
|
@ -67,11 +67,11 @@ def test_location_db():
|
||||||
assert constants.location_db == '{}/location.json'.format(constants.application_directory), constants.location_db
|
assert constants.location_db == '{}/location.json'.format(constants.application_directory), constants.location_db
|
||||||
|
|
||||||
def test_script_directory():
|
def test_script_directory():
|
||||||
path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
path = os.path.dirname(os.path.dirname(__file__))
|
||||||
assert path == constants.script_directory, constants.script_directory
|
assert path == constants.script_directory, constants.script_directory
|
||||||
|
|
||||||
def test_exiftool_config():
|
def test_exiftool_config():
|
||||||
path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
path = constants.script_directory
|
||||||
assert '{}/configs/ExifTool_config'.format(path) == constants.exiftool_config, constants.exiftool_config
|
assert '{}/configs/ExifTool_config'.format(path) == constants.exiftool_config, constants.exiftool_config
|
||||||
|
|
||||||
def test_mapquest_base_url_default():
|
def test_mapquest_base_url_default():
|
||||||
|
|
|
@ -11,11 +11,10 @@ from nose.tools import assert_raises
|
||||||
from six import text_type, unichr as six_unichr
|
from six import text_type, unichr as six_unichr
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
|
# sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
|
|
||||||
|
|
||||||
import helper
|
import helper
|
||||||
elodie = load_source('elodie', os.path.abspath('{}/../../elodie.py'.format(os.path.dirname(os.path.realpath(__file__)))))
|
elodie = load_source('elodie', os.path.abspath('{}/../elodie.py'.format(os.path.dirname(os.path.realpath(__file__)))))
|
||||||
|
|
||||||
from elodie.config import load_config
|
from elodie.config import load_config
|
||||||
from elodie.localstorage import Db
|
from elodie.localstorage import Db
|
||||||
|
@ -27,22 +26,6 @@ from elodie.plugins.googlephotos.googlephotos import GooglePhotos
|
||||||
|
|
||||||
os.environ['TZ'] = 'GMT'
|
os.environ['TZ'] = 'GMT'
|
||||||
|
|
||||||
def test_import_file_text():
|
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
|
||||||
|
|
||||||
helper.reset_dbs()
|
|
||||||
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
|
||||||
helper.restore_dbs()
|
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
|
||||||
shutil.rmtree(folder_destination)
|
|
||||||
|
|
||||||
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London','2016-04-07_11-15-26-valid-sample-title.txt')) in dest_path, dest_path
|
|
||||||
|
|
||||||
def test_import_file_audio():
|
def test_import_file_audio():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
@ -95,11 +78,11 @@ def test_import_file_path_utf8_encoded_ascii_checkmark():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = text_type(folder)+u'/unicode\u2713filename.txt'
|
origin = text_type(folder)+u'/unicode\u2713filename.png'
|
||||||
# encode the unicode string to ascii
|
# encode the unicode string to ascii
|
||||||
origin = origin.encode('utf-8')
|
origin = origin.encode('utf-8')
|
||||||
|
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -108,15 +91,15 @@ def test_import_file_path_utf8_encoded_ascii_checkmark():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\u2713filename-sample-title.txt')) in dest_path, dest_path
|
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\u2713filename-sample-title.png')) in dest_path, dest_path
|
||||||
|
|
||||||
def test_import_file_path_unicode_checkmark():
|
def test_import_file_path_unicode_checkmark():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = text_type(folder)+u'/unicode\u2713filename.txt'
|
origin = text_type(folder)+u'/unicode\u2713filename.png'
|
||||||
|
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -125,17 +108,17 @@ def test_import_file_path_unicode_checkmark():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\u2713filename-sample-title.txt')) in dest_path, dest_path
|
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\u2713filename-sample-title.png')) in dest_path, dest_path
|
||||||
|
|
||||||
def test_import_file_path_utf8_encoded_ascii_latin_nbsp():
|
def test_import_file_path_utf8_encoded_ascii_latin_nbsp():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = text_type(folder)+u'/unicode'+six_unichr(160)+u'filename.txt'
|
origin = text_type(folder)+u'/unicode'+six_unichr(160)+u'filename.png'
|
||||||
# encode the unicode string to ascii
|
# encode the unicode string to ascii
|
||||||
origin = origin.encode('utf-8')
|
origin = origin.encode('utf-8')
|
||||||
|
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -144,15 +127,15 @@ def test_import_file_path_utf8_encoded_ascii_latin_nbsp():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.txt')) in dest_path, dest_path
|
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.png')) in dest_path, dest_path
|
||||||
|
|
||||||
def test_import_file_path_unicode_latin_nbsp():
|
def test_import_file_path_unicode_latin_nbsp():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = text_type(folder)+u'/unicode'+six_unichr(160)+u'filename.txt'
|
origin = text_type(folder)+u'/unicode'+six_unichr(160)+u'filename.png'
|
||||||
|
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -161,14 +144,14 @@ def test_import_file_path_unicode_latin_nbsp():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.txt')) in dest_path, dest_path
|
assert helper.path_tz_fix(os.path.join('2016-04-Apr','London',u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.png')) in dest_path, dest_path
|
||||||
|
|
||||||
def test_import_file_allow_duplicate_false():
|
def test_import_file_allow_duplicate_false():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path1 = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path1 = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -185,8 +168,8 @@ def test_import_file_allow_duplicate_true():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path1 = elodie.import_file(origin, folder_destination, False, False, True)
|
dest_path1 = elodie.import_file(origin, folder_destination, False, False, True)
|
||||||
|
@ -204,8 +187,8 @@ def test_import_file_send_to_trash_false():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path1 = elodie.import_file(origin, folder_destination, False, False, False)
|
dest_path1 = elodie.import_file(origin, folder_destination, False, False, False)
|
||||||
|
@ -223,8 +206,8 @@ def test_import_file_send_to_trash_true():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
dest_path1 = elodie.import_file(origin, folder_destination, False, True, False)
|
dest_path1 = elodie.import_file(origin, folder_destination, False, True, False)
|
||||||
|
@ -276,7 +259,7 @@ def test_import_invalid_file_exit_code():
|
||||||
origin_invalid = '%s/invalid.jpg' % folder
|
origin_invalid = '%s/invalid.jpg' % folder
|
||||||
shutil.copyfile(helper.get_file('invalid.jpg'), origin_invalid)
|
shutil.copyfile(helper.get_file('invalid.jpg'), origin_invalid)
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
|
@ -293,7 +276,7 @@ def test_import_file_with_single_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -306,7 +289,7 @@ def test_import_file_with_multiple_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -319,7 +302,7 @@ def test_import_file_with_non_matching_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -332,7 +315,7 @@ def test_import_directory_with_matching_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -345,7 +328,7 @@ def test_import_directory_with_non_matching_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -369,7 +352,7 @@ def test_import_file_with_single_config_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -397,7 +380,7 @@ def test_import_file_with_multiple_config_exclude():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -505,8 +488,8 @@ def test_update_time_on_audio():
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
assert metadata['date_taken'] != metadata_processed['date_taken']
|
assert metadata['date_original'] != metadata_processed['date_original']
|
||||||
assert metadata_processed['date_taken'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_taken']
|
assert metadata_processed['date_original'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_original']
|
||||||
|
|
||||||
def test_update_time_on_photo():
|
def test_update_time_on_photo():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
@ -529,8 +512,8 @@ def test_update_time_on_photo():
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
assert metadata['date_taken'] != metadata_processed['date_taken']
|
assert metadata['date_original'] != metadata_processed['date_original']
|
||||||
assert metadata_processed['date_taken'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_taken']
|
assert metadata_processed['date_original'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_original']
|
||||||
|
|
||||||
def test_update_time_on_video():
|
def test_update_time_on_video():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
@ -553,15 +536,15 @@ def test_update_time_on_video():
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
assert metadata['date_taken'] != metadata_processed['date_taken']
|
assert metadata['date_original'] != metadata_processed['date_original']
|
||||||
assert metadata_processed['date_taken'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_taken']
|
assert metadata_processed['date_original'] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_original']
|
||||||
|
|
||||||
def test_update_with_directory_passed_in():
|
def test_update_with_directory_passed_in():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
temporary_folder_destination, folder_destination = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -570,7 +553,7 @@ def test_update_with_directory_passed_in():
|
||||||
result = runner2.invoke(elodie._update, ['--album', 'test', folder_destination])
|
result = runner2.invoke(elodie._update, ['--album', 'test', folder_destination])
|
||||||
helper.restore_dbs()
|
helper.restore_dbs()
|
||||||
|
|
||||||
updated_file_path = "{}/2016-04-Apr/test/2016-04-07_11-15-26-valid-sample-title.txt".format(folder_destination)
|
updated_file_path = "{}/2016-04-Apr/test/2016-04-07_11-15-26-valid-sample-title.png".format(folder_destination)
|
||||||
updated_file_exists = os.path.isfile(updated_file_path)
|
updated_file_exists = os.path.isfile(updated_file_path)
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
@ -586,7 +569,7 @@ def test_update_invalid_file_exit_code():
|
||||||
origin_invalid = '%s/invalid.jpg' % folder
|
origin_invalid = '%s/invalid.jpg' % folder
|
||||||
shutil.copyfile(helper.get_file('invalid.jpg'), origin_invalid)
|
shutil.copyfile(helper.get_file('invalid.jpg'), origin_invalid)
|
||||||
|
|
||||||
origin_valid = '%s/valid.jpg' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
shutil.copyfile(helper.get_file('plain.jpg'), origin_valid)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
|
@ -594,7 +577,8 @@ def test_update_invalid_file_exit_code():
|
||||||
result = runner.invoke(elodie._update, ['--album', 'test', origin_invalid, origin_valid])
|
result = runner.invoke(elodie._update, ['--album', 'test', origin_invalid, origin_valid])
|
||||||
helper.restore_dbs()
|
helper.restore_dbs()
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
# bugfix deleted by elodie._update....
|
||||||
|
# shutil.rmtree(folder)
|
||||||
shutil.rmtree(folder_destination)
|
shutil.rmtree(folder_destination)
|
||||||
|
|
||||||
assert result.exit_code == 1, result.exit_code
|
assert result.exit_code == 1, result.exit_code
|
||||||
|
@ -607,8 +591,8 @@ def test_regenerate_db_invalid_source():
|
||||||
def test_regenerate_valid_source():
|
def test_regenerate_valid_source():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -624,8 +608,8 @@ def test_regenerate_valid_source():
|
||||||
def test_regenerate_valid_source_with_invalid_files():
|
def test_regenerate_valid_source_with_invalid_files():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin_valid = '%s/valid.txt' % folder
|
origin_valid = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin_valid)
|
shutil.copyfile(helper.get_file('photo.png'), origin_valid)
|
||||||
origin_invalid = '%s/invalid.invalid' % folder
|
origin_invalid = '%s/invalid.invalid' % folder
|
||||||
shutil.copyfile(helper.get_file('invalid.invalid'), origin_invalid)
|
shutil.copyfile(helper.get_file('invalid.invalid'), origin_invalid)
|
||||||
|
|
||||||
|
@ -644,8 +628,8 @@ def test_regenerate_valid_source_with_invalid_files():
|
||||||
def test_verify_ok():
|
def test_verify_ok():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
@ -661,8 +645,8 @@ def test_verify_ok():
|
||||||
def test_verify_error():
|
def test_verify_error():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/valid.txt' % folder
|
origin = '%s/photo.png' % folder
|
||||||
shutil.copyfile(helper.get_file('valid.txt'), origin)
|
shutil.copyfile(helper.get_file('photo.png'), origin)
|
||||||
|
|
||||||
helper.reset_dbs()
|
helper.reset_dbs()
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|
|
@ -1091,12 +1091,14 @@ def test_set_utime_with_exif_date():
|
||||||
|
|
||||||
initial_stat = os.stat(origin)
|
initial_stat = os.stat(origin)
|
||||||
initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
|
initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
|
||||||
|
initial_time = datetime.fromtimestamp(initial_time)
|
||||||
initial_checksum = helper.checksum(origin)
|
initial_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
assert initial_time != time.mktime(metadata_initial['date_taken'])
|
assert initial_time != metadata_initial['date_original']
|
||||||
|
|
||||||
filesystem.set_utime_from_metadata(media_initial.get_metadata(), media_initial.get_file_path())
|
filesystem.set_utime_from_metadata(metadata_initial['date_original'], media_initial.get_file_path())
|
||||||
final_stat = os.stat(origin)
|
final_stat = os.stat(origin)
|
||||||
|
final_time = datetime.fromtimestamp(final_stat.st_mtime)
|
||||||
final_checksum = helper.checksum(origin)
|
final_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
media_final = Photo(origin)
|
media_final = Photo(origin)
|
||||||
|
@ -1105,7 +1107,7 @@ def test_set_utime_with_exif_date():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert initial_stat.st_mtime != final_stat.st_mtime
|
assert initial_stat.st_mtime != final_stat.st_mtime
|
||||||
assert final_stat.st_mtime == time.mktime(metadata_final['date_taken'])
|
assert final_time == metadata_final['date_original']
|
||||||
assert initial_checksum == final_checksum
|
assert initial_checksum == final_checksum
|
||||||
|
|
||||||
def test_set_utime_without_exif_date():
|
def test_set_utime_without_exif_date():
|
||||||
|
@ -1120,12 +1122,14 @@ def test_set_utime_without_exif_date():
|
||||||
|
|
||||||
initial_stat = os.stat(origin)
|
initial_stat = os.stat(origin)
|
||||||
initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
|
initial_time = int(min(initial_stat.st_mtime, initial_stat.st_ctime))
|
||||||
|
initial_time = datetime.fromtimestamp(initial_time)
|
||||||
initial_checksum = helper.checksum(origin)
|
initial_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
assert initial_time == time.mktime(metadata_initial['date_taken'])
|
assert initial_time == metadata_initial['date_original']
|
||||||
|
|
||||||
filesystem.set_utime_from_metadata(media_initial.get_metadata(), media_initial.get_file_path())
|
filesystem.set_utime_from_metadata(metadata_initial['date_original'], media_initial.get_file_path())
|
||||||
final_stat = os.stat(origin)
|
final_stat = os.stat(origin)
|
||||||
|
final_time = datetime.fromtimestamp(final_stat.st_mtime)
|
||||||
final_checksum = helper.checksum(origin)
|
final_checksum = helper.checksum(origin)
|
||||||
|
|
||||||
media_final = Photo(origin)
|
media_final = Photo(origin)
|
||||||
|
@ -1134,7 +1138,7 @@ def test_set_utime_without_exif_date():
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert initial_time == final_stat.st_mtime
|
assert initial_time == final_stat.st_mtime
|
||||||
assert final_stat.st_mtime == time.mktime(metadata_final['date_taken']), (final_stat.st_mtime, time.mktime(metadata_final['date_taken']))
|
assert final_time == metadata_final['date_original'], (final_time, metadata_final['date_original'])
|
||||||
assert initial_checksum == final_checksum
|
assert initial_checksum == final_checksum
|
||||||
|
|
||||||
def test_should_exclude_with_no_exclude_arg():
|
def test_should_exclude_with_no_exclude_arg():
|
||||||
|
|
|
@ -7,7 +7,7 @@ import sys
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
|
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
|
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
|
||||||
|
@ -73,10 +73,10 @@ def test_get_coordinate_longitude():
|
||||||
assert helper.isclose(coordinate, -95.3677), coordinate
|
assert helper.isclose(coordinate, -95.3677), coordinate
|
||||||
|
|
||||||
def test_get_date_original():
|
def test_get_date_original():
|
||||||
media = Media(helper.get_file('audio.m4a'))
|
audio = Audio(helper.get_file('audio.m4a'))
|
||||||
date_original = media.get_date_attribute('date_original')
|
date_created = audio.get_date_attribute(audio.date_original)
|
||||||
|
|
||||||
assert date_original == (2016, 1, 4, 5, 28, 15, 0, 4, 0), date_original
|
assert date_created.strftime('%Y-%m-%d %H:%M:%S') == '2016-01-03 21:23:39', date_created
|
||||||
|
|
||||||
def test_get_exiftool_attributes():
|
def test_get_exiftool_attributes():
|
||||||
audio = Video(helper.get_file('audio.m4a'))
|
audio = Video(helper.get_file('audio.m4a'))
|
||||||
|
@ -91,7 +91,7 @@ def test_is_valid():
|
||||||
assert audio.is_valid()
|
assert audio.is_valid()
|
||||||
|
|
||||||
def test_is_not_valid():
|
def test_is_not_valid():
|
||||||
audio = Audio(helper.get_file('text.txt'))
|
audio = Audio(helper.get_file('photo.png'))
|
||||||
|
|
||||||
assert not audio.is_valid()
|
assert not audio.is_valid()
|
||||||
|
|
||||||
|
@ -102,18 +102,19 @@ def test_set_date_original():
|
||||||
shutil.copyfile(helper.get_file('audio.m4a'), origin)
|
shutil.copyfile(helper.get_file('audio.m4a'), origin)
|
||||||
|
|
||||||
media = Media(origin)
|
media = Media(origin)
|
||||||
status = media.set_date_original(datetime.datetime(2013, 9, 30, 7, 6, 5))
|
date = datetime(2013, 9, 30, 7, 6, 5)
|
||||||
|
status = media.set_date_original(date)
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
|
|
||||||
audio_new = Audio(origin)
|
audio_new = Audio(origin)
|
||||||
metadata = audio_new.get_metadata()
|
metadata = audio_new.get_metadata()
|
||||||
|
|
||||||
date_original = metadata['date_original']
|
date_original = metadata['date_created']
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert date_original == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_original']
|
assert date_original == date, date_original
|
||||||
|
|
||||||
def test_set_location():
|
def test_set_location():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
|
@ -71,9 +71,8 @@ def test_set_album_from_folder_invalid_file():
|
||||||
|
|
||||||
shutil.copyfile(base_file, origin)
|
shutil.copyfile(base_file, origin)
|
||||||
|
|
||||||
base = Base(origin)
|
media = Media(origin)
|
||||||
|
status = media.set_album_from_folder()
|
||||||
status = base.set_album_from_folder()
|
|
||||||
|
|
||||||
assert status == False, status
|
assert status == False, status
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ def test_is_valid():
|
||||||
assert photo.is_valid()
|
assert photo.is_valid()
|
||||||
|
|
||||||
def test_is_not_valid():
|
def test_is_not_valid():
|
||||||
photo = Photo(helper.get_file('text.txt'))
|
photo = Photo(helper.get_file('video.mov'))
|
||||||
|
|
||||||
assert not photo.is_valid()
|
assert not photo.is_valid()
|
||||||
|
|
||||||
|
@ -124,10 +124,10 @@ def test_get_coordinates_with_null_coordinate():
|
||||||
|
|
||||||
def test_get_date_original():
|
def test_get_date_original():
|
||||||
media = Media(helper.get_file('plain.jpg'))
|
media = Media(helper.get_file('plain.jpg'))
|
||||||
date_original = media.get_date_attribute('date_original')
|
date_original = media.get_date_attribute(['EXIF:DateTimeOriginal'])
|
||||||
|
|
||||||
#assert date_original == (2015, 12, 5, 0, 59, 26, 5, 339, 0), date_original
|
#assert date_original == (2015, 12, 5, 0, 59, 26, 5, 339, 0), date_original
|
||||||
assert date_original == helper.time_convert((2015, 12, 5, 0, 59, 26, 5, 339, 0)), date_original
|
assert date_original == datetime(2015, 12, 5, 0, 59, 26), date_original
|
||||||
|
|
||||||
def test_get_camera_make():
|
def test_get_camera_make():
|
||||||
photo = Photo(helper.get_file('with-location.jpg'))
|
photo = Photo(helper.get_file('with-location.jpg'))
|
||||||
|
@ -153,16 +153,6 @@ def test_get_camera_model_not_set():
|
||||||
|
|
||||||
assert model is None, model
|
assert model is None, model
|
||||||
|
|
||||||
def test_is_valid():
|
|
||||||
photo = Photo(helper.get_file('with-location.jpg'))
|
|
||||||
|
|
||||||
assert photo.is_valid()
|
|
||||||
|
|
||||||
def test_is_not_valid():
|
|
||||||
photo = Photo(helper.get_file('text.txt'))
|
|
||||||
|
|
||||||
assert not photo.is_valid()
|
|
||||||
|
|
||||||
def test_is_valid_fallback_using_pillow():
|
def test_is_valid_fallback_using_pillow():
|
||||||
photo = Photo(helper.get_file('imghdr-error.jpg'))
|
photo = Photo(helper.get_file('imghdr-error.jpg'))
|
||||||
|
|
||||||
|
@ -205,7 +195,8 @@ def test_set_date_original_with_missing_datetimeoriginal():
|
||||||
shutil.copyfile(helper.get_file('no-exif.jpg'), origin)
|
shutil.copyfile(helper.get_file('no-exif.jpg'), origin)
|
||||||
|
|
||||||
media = Media(origin)
|
media = Media(origin)
|
||||||
status = media.set_date_original(datetime.now())
|
time = datetime(2013, 9, 30, 7, 6, 5)
|
||||||
|
status = media.set_date_original(time)
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
|
|
||||||
|
@ -218,7 +209,7 @@ def test_set_date_original_with_missing_datetimeoriginal():
|
||||||
|
|
||||||
#assert date_original == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_original']
|
#assert date_original == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_original']
|
||||||
# assert date_original == helper.time_convert((2013, 9, 30, 7, 6, 5, 0, 273, 0)), metadata['date_original']
|
# assert date_original == helper.time_convert((2013, 9, 30, 7, 6, 5, 0, 273, 0)), metadata['date_original']
|
||||||
assert date_original == datetime.now(), metadata['date_original']
|
assert date_original == time, metadata['date_original']
|
||||||
|
|
||||||
def test_set_date_original():
|
def test_set_date_original():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
@ -231,15 +222,15 @@ def test_set_date_original():
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
|
|
||||||
photo_new = Photo(origin)
|
media_new = Media(origin)
|
||||||
metadata = photo_new.get_metadata()
|
metadata = media_new.get_metadata()
|
||||||
|
|
||||||
date_original = metadata['date_original']
|
date_original = metadata['date_original']
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
#assert date_original == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_original']
|
#assert date_original == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_original']
|
||||||
assert date_original == helper.time_convert((2013, 9, 30, 7, 6, 5, 0, 273, 0)), metadata['date_original']
|
assert date_original == datetime(2013, 9, 30, 7, 6, 5), metadata['date_original']
|
||||||
|
|
||||||
def test_set_location():
|
def test_set_location():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
@ -343,13 +334,13 @@ def test_various_types():
|
||||||
types = Photo.extensions
|
types = Photo.extensions
|
||||||
#extensions = ('arw', 'cr2', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2')
|
#extensions = ('arw', 'cr2', 'dng', 'gif', 'jpeg', 'jpg', 'nef', 'rw2')
|
||||||
dates = {
|
dates = {
|
||||||
'arw': (2007, 4, 8, 17, 41, 18, 6, 98, 0),
|
'arw': datetime(2007, 4, 8, 17, 41, 18),
|
||||||
'cr2': (2005, 10, 29, 16, 14, 44, 5, 302, 0),
|
'cr2': datetime(2005, 10, 29, 16, 14, 44),
|
||||||
'dng': (2009, 10, 20, 9, 10, 46, 1, 293, 0),
|
'dng': datetime(2009, 10, 20, 9, 10, 46),
|
||||||
'heic': (2019, 5, 26, 10, 33, 20, 6, 146, 0),
|
'heic': datetime(2019, 5, 26, 10, 33, 20),
|
||||||
'nef': (2008, 10, 24, 9, 12, 56, 4, 298, 0),
|
'nef': datetime(2008, 10, 24, 9, 12, 56),
|
||||||
'png': (2015, 1, 18, 12, 1, 1, 6, 18, 0),
|
'png': datetime(2015, 1, 18, 12, 1, 1),
|
||||||
'rw2': (2014, 11, 19, 23, 7, 44, 2, 323, 0)
|
'rw2': datetime(2014, 11, 19, 23, 7, 44)
|
||||||
}
|
}
|
||||||
|
|
||||||
for type in types:
|
for type in types:
|
||||||
|
@ -367,7 +358,7 @@ def _test_photo_type_get(type, date):
|
||||||
if not photo_file:
|
if not photo_file:
|
||||||
photo_file = helper.download_file(photo_name, folder)
|
photo_file = helper.download_file(photo_name, folder)
|
||||||
if not photo_file or not os.path.isfile(photo_file):
|
if not photo_file or not os.path.isfile(photo_file):
|
||||||
raise SkipTest('{} file not downlaoded'.format(type))
|
raise SkipTest('{} file not downloaded'.format(type))
|
||||||
|
|
||||||
# downloading for each test is costly so we save it in the working directory
|
# downloading for each test is costly so we save it in the working directory
|
||||||
file_path_save_as = helper.get_file_path(photo_name)
|
file_path_save_as = helper.get_file_path(photo_name)
|
||||||
|
@ -381,7 +372,7 @@ def _test_photo_type_get(type, date):
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert metadata['date_original'] == helper.time_convert(date), '{} date {}'.format(type, metadata['date_original'])
|
assert metadata['date_original'] == date, metadata['date_original']
|
||||||
|
|
||||||
def _test_photo_type_set(type, date):
|
def _test_photo_type_set(type, date):
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
@ -393,7 +384,7 @@ def _test_photo_type_set(type, date):
|
||||||
if not photo_file:
|
if not photo_file:
|
||||||
photo_file = helper.download_file(photo_name, folder)
|
photo_file = helper.download_file(photo_name, folder)
|
||||||
if not photo_file or not os.path.isfile(photo_file):
|
if not photo_file or not os.path.isfile(photo_file):
|
||||||
raise SkipTest('{} file not downlaoded'.format(type))
|
raise SkipTest('{} file not downloaded'.format(type))
|
||||||
|
|
||||||
shutil.copyfile(photo_file, origin)
|
shutil.copyfile(photo_file, origin)
|
||||||
|
|
||||||
|
@ -409,6 +400,6 @@ def _test_photo_type_set(type, date):
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert metadata['date_original'] == helper.time_convert(date), '{} date {}'.format(type, metadata['date_original'])
|
assert metadata['date_original'] == date, metadata['date_original']
|
||||||
assert helper.isclose(metadata['latitude'], 11.1111111111), '{} lat {}'.format(type, metadata['latitude'])
|
assert helper.isclose(metadata['latitude'], 11.1111111111), '{} lat {}'.format(type, metadata['latitude'])
|
||||||
assert helper.isclose(metadata['longitude'], 99.9999999999), '{} lon {}'.format(type, metadata['latitude'])
|
assert helper.isclose(metadata['longitude'], 99.9999999999), '{} lon {}'.format(type, metadata['latitude'])
|
||||||
|
|
|
@ -6,7 +6,8 @@ import sys
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import datetime
|
from datetime import datetime
|
||||||
|
from dateutil.parser import parse
|
||||||
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
|
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))))
|
||||||
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
|
sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
|
||||||
|
@ -66,11 +67,12 @@ def test_get_coordinate_longitude():
|
||||||
|
|
||||||
assert coordinate == -119.9558, coordinate
|
assert coordinate == -119.9558, coordinate
|
||||||
|
|
||||||
def test_get_date_taken():
|
def test_get_date_original():
|
||||||
video = Video(helper.get_file('video.mov'))
|
media = Media(helper.get_file('video.mov'))
|
||||||
date_taken = video.get_date_taken()
|
date_original = media.get_date_attribute(['QuickTime:ContentCreateDate'])
|
||||||
|
date = parse('2015-01-19 12:45:11-08:00')
|
||||||
|
|
||||||
assert date_taken == (2015, 1, 19, 12, 45, 11, 0, 19, 0), date_taken
|
assert date_original == date, date_original
|
||||||
|
|
||||||
def test_get_exiftool_attributes():
|
def test_get_exiftool_attributes():
|
||||||
video = Video(helper.get_file('video.mov'))
|
video = Video(helper.get_file('video.mov'))
|
||||||
|
@ -85,7 +87,7 @@ def test_is_valid():
|
||||||
assert video.is_valid()
|
assert video.is_valid()
|
||||||
|
|
||||||
def test_is_not_valid():
|
def test_is_not_valid():
|
||||||
video = Video(helper.get_file('text.txt'))
|
video = Video(helper.get_file('photo.png'))
|
||||||
|
|
||||||
assert not video.is_valid()
|
assert not video.is_valid()
|
||||||
|
|
||||||
|
@ -111,25 +113,25 @@ def test_set_album():
|
||||||
|
|
||||||
assert metadata_new['album'] == 'Test Album', metadata_new['album']
|
assert metadata_new['album'] == 'Test Album', metadata_new['album']
|
||||||
|
|
||||||
def test_set_date_taken():
|
def test_set_date_original():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
||||||
origin = '%s/video.mov' % folder
|
origin = '%s/video.mov' % folder
|
||||||
shutil.copyfile(helper.get_file('video.mov'), origin)
|
shutil.copyfile(helper.get_file('video.mov'), origin)
|
||||||
|
|
||||||
video = Video(origin)
|
media = Media(origin)
|
||||||
status = video.set_date_taken(datetime.datetime(2013, 9, 30, 7, 6, 5))
|
status = media.set_date_original(datetime(2013, 9, 30, 7, 6, 5))
|
||||||
|
|
||||||
assert status == True, status
|
assert status == True, status
|
||||||
|
|
||||||
video_new = Video(origin)
|
media_new = Media(origin)
|
||||||
metadata = video_new.get_metadata()
|
metadata = media_new.get_metadata()
|
||||||
|
|
||||||
date_taken = metadata['date_taken']
|
date_original = metadata['date_original']
|
||||||
|
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
|
||||||
assert date_taken == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_taken']
|
assert date_original == datetime(2013, 9, 30, 7, 6, 5), metadata['date_original']
|
||||||
|
|
||||||
def test_set_location():
|
def test_set_location():
|
||||||
temporary_folder, folder = helper.create_working_folder()
|
temporary_folder, folder = helper.create_working_folder()
|
||||||
|
|
Loading…
Reference in New Issue