<s> from imp import load_source <EOL> import os <EOL> import sys <EOL> import shutil <EOL> from nose . plugins . skip import SkipTest <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( os . path . dirname ( os . path . dirname ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) ) ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , os . path . abspath ( os . path . dirname ( os . path . dirname ( os . path . dirname ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) ) ) ) ) <EOL> import helper <EOL> elodie = load_source ( '<STR_LIT>' , os . path . abspath ( '<STR_LIT>' . format ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) ) ) <EOL> from elodie import constants <EOL> from elodie . media . audio import Audio <EOL> from elodie . media . photo import Photo <EOL> from elodie . media . text import Text <EOL> from elodie . media . video import Video <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def test_import_file_text ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> reset_hash_db ( ) <EOL> dest_path = elodie . import_file ( origin , folder_destination , False , False ) <EOL> restore_hash_db ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert helper . path_tz_fix ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) in dest_path , dest_path <EOL> def test_import_file_audio ( ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> reset_hash_db ( ) <EOL> dest_path = elodie . import_file ( origin , folder_destination , False , False ) <EOL> restore_hash_db ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert helper . path_tz_fix ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) in dest_path , dest_path <EOL> def test_import_file_photo ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> reset_hash_db ( ) <EOL> dest_path = elodie . import_file ( origin , folder_destination , False , False ) <EOL> restore_hash_db ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert helper . path_tz_fix ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) in dest_path , dest_path <EOL> def test_import_file_video ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> reset_hash_db ( ) <EOL> dest_path = elodie . import_file ( origin , folder_destination , False , False ) <EOL> restore_hash_db ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert helper . path_tz_fix ( os . path . join ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) in dest_path , dest_path <EOL> def test_update_location_on_audio ( ) : <EOL> if not can_edit_exif ( ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> audio = Audio ( origin ) <EOL> metadata = audio . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_location ( audio , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> audio_processed = Audio ( origin ) <EOL> metadata_processed = audio_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , - <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_location_on_photo ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> photo = Photo ( origin ) <EOL> metadata = photo . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_location ( photo , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> photo_processed = Photo ( origin ) <EOL> metadata_processed = photo_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , - <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_location_on_text ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> text = Text ( origin ) <EOL> metadata = text . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_location ( text , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> text_processed = Text ( origin ) <EOL> metadata_processed = text_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , - <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_location_on_video ( ) : <EOL> if not can_edit_exif ( ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> video = Video ( origin ) <EOL> metadata = video . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_location ( video , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> video_processed = Video ( origin ) <EOL> metadata_processed = video_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> assert helper . isclose ( metadata_processed [ '<STR_LIT>' ] , - <NUM_LIT> ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_time_on_audio ( ) : <EOL> if not can_edit_exif ( ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> audio = Audio ( origin ) <EOL> metadata = audio . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_time ( audio , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> audio_processed = Audio ( origin ) <EOL> metadata_processed = audio_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert metadata_processed [ '<STR_LIT>' ] == helper . time_convert ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:0> ) ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_time_on_photo ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> photo = Photo ( origin ) <EOL> metadata = photo . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_time ( photo , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> photo_processed = Photo ( origin ) <EOL> metadata_processed = photo_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert metadata_processed [ '<STR_LIT>' ] == helper . time_convert ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:0> ) ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_time_on_text ( ) : <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> text = Text ( origin ) <EOL> metadata = text . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_time ( text , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> text_processed = Text ( origin ) <EOL> metadata_processed = text_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert metadata_processed [ '<STR_LIT>' ] == helper . time_convert ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:0> ) ) , metadata_processed [ '<STR_LIT>' ] <EOL> def test_update_time_on_video ( ) : <EOL> if not can_edit_exif ( ) : <EOL> raise SkipTest ( '<STR_LIT>' ) <EOL> temporary_folder , folder = helper . create_working_folder ( ) <EOL> temporary_folder_destination , folder_destination = helper . create_working_folder ( ) <EOL> origin = '<STR_LIT>' % folder <EOL> shutil . copyfile ( helper . get_file ( '<STR_LIT>' ) , origin ) <EOL> video = Video ( origin ) <EOL> metadata = video . get_metadata ( ) <EOL> reset_hash_db ( ) <EOL> status = elodie . update_time ( video , origin , '<STR_LIT>' ) <EOL> restore_hash_db ( ) <EOL> video_processed = Video ( origin ) <EOL> metadata_processed = video_processed . get_metadata ( ) <EOL> shutil . rmtree ( folder ) <EOL> shutil . rmtree ( folder_destination ) <EOL> assert status == True , status <EOL> assert metadata [ '<STR_LIT>' ] != metadata_processed [ '<STR_LIT>' ] <EOL> assert metadata_processed [ '<STR_LIT>' ] == helper . time_convert ( ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:12> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:5> , <NUM_LIT:1> , <NUM_LIT:0> ) ) , metadata_processed [ '<STR_LIT>' ] <EOL> def reset_hash_db ( ) : <EOL> hash_db = constants . hash_db <EOL> if os . path . isfile ( hash_db ) : <EOL> os . rename ( hash_db , '<STR_LIT>' . format ( hash_db ) ) <EOL> def restore_hash_db ( ) : <EOL> hash_db = '<STR_LIT>' . format ( constants . hash_db ) <EOL> if os . path . isfile ( hash_db ) : <EOL> os . rename ( hash_db , hash_db . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> def can_edit_exif ( ) : <EOL> video = Video ( ) <EOL> return video . get_avmetareadwrite ( ) </s>
