def test_set_location(): if not can_edit_exif(): raise SkipTest('avmetareadwrite executable not found') temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() # Verify that original audio has different location info that what we # will be setting and checking assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude'] assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude'] status = audio.set_location(11.1111111111, 99.9999999999) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude'] assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_set_location(): if not can_edit_exif(): raise SkipTest('avmetareadwrite executable not found') raise SkipTest('gh-31, precision is lost in conversion from decimal to dms') temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() # Verify that original photo has no location information #assert origin_metadata['latitude'] is None, origin_metadata['latitude'] #assert origin_metadata['longitude'] is None, origin_metadata['longitude'] status = audio.set_location(11.1111111111, 99.9999999999) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) # @TODO: understand why the decimal to degree conversion loses accuracy assert metadata['latitude'] == 11.1111111111, metadata['latitude'] assert metadata['longitude'] == 99.9999999999, metadata['longitude']
def test_set_location(): temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() # Verify that original audio has different location info that what we # will be setting and checking assert not helper.isclose(origin_metadata['latitude'], 11.1111111111), origin_metadata['latitude'] assert not helper.isclose(origin_metadata['longitude'], 99.9999999999), origin_metadata['longitude'] status = audio.set_location(11.1111111111, 99.9999999999) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert helper.isclose(metadata['latitude'], 11.1111111111), metadata['latitude'] assert helper.isclose(metadata['longitude'], 99.9999999999), metadata['longitude']
def test_update_time_on_audio(): temporary_folder, folder = helper.create_working_folder() temporary_folder_destination, folder_destination = helper.create_working_folder() origin = "%s/audio.m4a" % folder shutil.copyfile(helper.get_file("audio.m4a"), origin) audio = Audio(origin) metadata = audio.get_metadata() reset_hash_db() status = elodie.update_time(audio, origin, "2000-01-01 12:00:00") restore_hash_db() audio_processed = Audio(origin) metadata_processed = audio_processed.get_metadata() shutil.rmtree(folder) shutil.rmtree(folder_destination) assert status == True, status assert metadata["date_taken"] != metadata_processed["date_taken"] assert metadata_processed["date_taken"] == helper.time_convert((2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed[ "date_taken" ]
def test_set_location_minus(): temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() # Verify that original audio has different location info that what we # will be setting and checking assert not helper.isclose(origin_metadata['latitude'], 11.111111), origin_metadata['latitude'] assert not helper.isclose(origin_metadata['longitude'], 99.999999), origin_metadata['longitude'] status = audio.set_location(-11.111111, -99.999999) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert helper.isclose(metadata['latitude'], -11.111111), metadata['latitude'] assert helper.isclose(metadata['longitude'], -99.999999), metadata['longitude']
def test_update_location_on_audio(): temporary_folder, folder = helper.create_working_folder() temporary_folder_destination, folder_destination = helper.create_working_folder( ) origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) metadata = audio.get_metadata() helper.reset_dbs() status = elodie.update_location(audio, origin, 'Sunnyvale, CA') helper.restore_dbs() audio_processed = Audio(origin) metadata_processed = audio_processed.get_metadata() shutil.rmtree(folder) shutil.rmtree(folder_destination) assert status == True, status assert metadata['latitude'] != metadata_processed[ 'latitude'], metadata_processed['latitude'] assert helper.isclose(metadata_processed['latitude'], 37.36883), metadata_processed['latitude'] assert helper.isclose(metadata_processed['longitude'], -122.03635), metadata_processed['longitude']
def test_set_location(): if not can_edit_exif(): raise SkipTest('avmetareadwrite executable not found') raise SkipTest( 'gh-31, precision is lost in conversion from decimal to dms') temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() # Verify that original photo has no location information #assert origin_metadata['latitude'] is None, origin_metadata['latitude'] #assert origin_metadata['longitude'] is None, origin_metadata['longitude'] status = audio.set_location(11.1111111111, 99.9999999999) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) # @TODO: understand why the decimal to degree conversion loses accuracy assert metadata['latitude'] == 11.1111111111, metadata['latitude'] assert metadata['longitude'] == 99.9999999999, metadata['longitude']
def test_update_time_on_audio(): temporary_folder, folder = helper.create_working_folder() temporary_folder_destination, folder_destination = helper.create_working_folder( ) origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) metadata = audio.get_metadata() helper.reset_dbs() status = elodie.update_time(audio, origin, '2000-01-01 12:00:00') helper.restore_dbs() audio_processed = Audio(origin) metadata_processed = audio_processed.get_metadata() shutil.rmtree(folder) shutil.rmtree(folder_destination) assert status == True, status assert metadata['date_taken'] != metadata_processed['date_taken'] assert metadata_processed['date_taken'] == helper.time_convert( (2000, 1, 1, 12, 0, 0, 5, 1, 0)), metadata_processed['date_taken']
def test_set_title(): temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() status = audio.set_title('my audio title') assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert metadata['title'] == 'my audio title', metadata['title']
def test_set_title_non_ascii(): temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() unicode_title = u'形声字 / 形聲字' status = audio.set_title(unicode_title) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert metadata['title'] == unicode_title, metadata['title']
def test_set_title(): if not can_edit_exif(): raise SkipTest('avmetareadwrite executable not found') temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) origin_metadata = audio.get_metadata() status = audio.set_title('my audio title') assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() shutil.rmtree(folder) assert metadata['title'] == 'my audio title', metadata['title']
def test_update_location_on_audio(): temporary_folder, folder = helper.create_working_folder() temporary_folder_destination, folder_destination = helper.create_working_folder() origin = "%s/audio.m4a" % folder shutil.copyfile(helper.get_file("audio.m4a"), origin) audio = Audio(origin) metadata = audio.get_metadata() reset_hash_db() status = elodie.update_location(audio, origin, "Sunnyvale, CA") restore_hash_db() audio_processed = Audio(origin) metadata_processed = audio_processed.get_metadata() shutil.rmtree(folder) shutil.rmtree(folder_destination) assert status == True, status assert metadata["latitude"] != metadata_processed["latitude"], metadata_processed["latitude"] assert helper.isclose(metadata_processed["latitude"], 37.36883), metadata_processed["latitude"] assert helper.isclose(metadata_processed["longitude"], -122.03635), metadata_processed["longitude"]
def test_googlephotos_after_unsupported(): with open('%s/config.ini-googlephotos-after-unsupported' % gettempdir(), 'w') as f: f.write(config_string_fmt) if hasattr(load_config, 'config'): del load_config.config final_file_path = helper.get_file('audio.m4a') sample_photo = Audio(final_file_path) sample_metadata = sample_photo.get_metadata() sample_metadata['original_name'] = 'foobar' gp = GooglePhotos() gp.after('', '', final_file_path, sample_metadata) db_row = gp.db.get(final_file_path) if hasattr(load_config, 'config'): del load_config.config assert db_row == None, db_row
def test_set_date_taken(): temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) status = audio.set_date_taken(datetime.datetime(2013, 9, 30, 7, 6, 5)) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() date_taken = metadata['date_taken'] shutil.rmtree(folder) assert date_taken == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_taken']
def test_set_date_taken(): if not can_edit_exif(): raise SkipTest('avmetareadwrite executable not found') temporary_folder, folder = helper.create_working_folder() origin = '%s/audio.m4a' % folder shutil.copyfile(helper.get_file('audio.m4a'), origin) audio = Audio(origin) status = audio.set_date_taken(datetime.datetime(2013, 9, 30, 7, 6, 5)) assert status == True, status audio_new = Audio(origin) metadata = audio_new.get_metadata() date_taken = metadata['date_taken'] shutil.rmtree(folder) assert date_taken == (2013, 9, 30, 7, 6, 5, 0, 273, 0), metadata['date_taken']