def test_get_folder_path_with_album_and_location_fallback(): # gh-279 with open('%s/config.ini-combined-date-album-location-fallback' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%Y-%m-%b custom=%album full_path=%custom|%city """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() # Test with no location media = Photo(helper.get_file('plain.jpg')) path_plain = filesystem.get_folder_path(media.get_metadata()) # Test with City media = Photo(helper.get_file('with-location.jpg')) path_city = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path_plain == 'Unknown Location', path_plain assert path_city == 'Sunnyvale', path_city
def test_get_folder_path_with_int_in_source_path(): # gh-239 filesystem = FileSystem() temporary_folder, folder = helper.create_working_folder('int') origin = os.path.join(folder,'plain.jpg') shutil.copyfile(helper.get_file('plain.jpg'), origin) media = Photo(origin) path = filesystem.get_folder_path(media.get_metadata()) assert path == os.path.join('2015-12-Dec','Unknown Location'), path
def test_get_folder_path_with_original_default_unknown_location(): with open('%s/config.ini-original-default-with-unknown-location' % gettempdir(), 'w') as f: f.write('') if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015-12-Dec','Unknown Location'), path
def test_get_folder_path_with_camera_make_and_model(): with open('%s/config.ini-original-with-camera-make-and-model' % gettempdir(), 'w') as f: f.write(""" [Directory] full_path=%camera_make/%camera_model """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('Canon', 'Canon EOS REBEL T2i'), path
def test_get_folder_path_with_camera_make_and_model_fallback(): with open('%s/config.ini-original-with-camera-make-and-model-fallback' % gettempdir(), 'w') as f: f.write(""" [Directory] full_path=%camera_make|"nomake"/%camera_model|"nomodel" """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('no-exif.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('nomake', 'nomodel'), path
def test_get_folder_path_with_int_in_config_component(): # gh-239 with open('%s/config.ini-int-in-component-path' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%Y full_path=%date """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015'), path
def test_get_folder_path_with_combined_date_and_album(): # gh-239 with open('%s/config.ini-combined-date-and-album' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%Y-%m-%b custom=%date %album full_path=%custom """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('with-album.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == '2015-12-Dec Test Album', path
def test_get_folder_path_with_with_only_one_level(): with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: f.write(""" [Directory] year=%Y full_path=%year """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015'), path
def test_get_folder_path_with_fallback_folder(): with open('%s/config.ini-fallback' % gettempdir(), 'w') as f: f.write(""" [Directory] year=%Y month=%m full_path=%year/%month/%album|%"No Album Fool"/%month """) #full_path=%year/%album|"No Album" if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015','12','No Album Fool','12'), path
def test_get_folder_path_with_custom_path(): with open('%s/config.ini-custom-path' % gettempdir(), 'w') as f: f.write(""" [MapQuest] key=czjNKTtFjLydLteUBwdgKAIC8OAbGLUx [Directory] date=%Y-%m-%d location=%country-%state-%city full_path=%date/%location """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('with-location.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015-12-05','United States of America-California-Sunnyvale'), path
def test_get_folder_path_with_with_more_than_two_levels(): with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: f.write(""" [MapQuest] key=czjNKTtFjLydLteUBwdgKAIC8OAbGLUx [Directory] year=%Y month=%m location=%city, %state full_path=%year/%month/%location """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() media = Photo(helper.get_file('with-location.jpg')) path = filesystem.get_folder_path(media.get_metadata()) if hasattr(load_config, 'config'): del load_config.config assert path == os.path.join('2015','12','Sunnyvale, California'), path
def test_get_folder_path_with_location_and_title(): filesystem = FileSystem() media = Photo(helper.get_file('with-location-and-title.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == os.path.join('2015-12-Dec', 'Sunnyvale'), path
def test_get_folder_path_with_title(): filesystem = FileSystem() media = Photo(helper.get_file('with-title.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == os.path.join('2015-12-Dec', 'Unknown Location'), path
def test_get_folder_path_plain(): filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == os.path.join('2015-12-Dec','Unknown Location'), path
def test_get_folder_path_with_location(): filesystem = FileSystem() media = Photo(helper.get_file('with-location.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == os.path.join('2015-12-Dec','Sunnyvale'), path
def test_get_folder_path_plain(): filesystem = FileSystem() media = Photo(helper.get_file('plain.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == '2015-12-Dec/Unknown Location', path
def test_get_folder_path_with_title(): filesystem = FileSystem() media = Photo(helper.get_file('with-title.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == '2015-12-Dec/Unknown Location', path
def test_get_folder_path_with_location(): filesystem = FileSystem() media = Photo(helper.get_file('with-location.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == '2015-12-Dec/Sunnyvale', path
def test_get_folder_path_with_location_and_title(): filesystem = FileSystem() media = Photo(helper.get_file('with-location-and-title.jpg')) path = filesystem.get_folder_path(media.get_metadata()) assert path == '2015-12-Dec/Sunnyvale', path