def test_get_folder_path_definition_cached(): with open('%s/config.ini-cached' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%Y-%m-%d location=%country full_path=%date/%location """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() expected = [ [('date', '%Y-%m-%d')], [('location', '%country')] ] assert path_definition == expected, path_definition with open('%s/config.ini-cached' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%uncached location=%uncached full_path=%date/%location """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() expected = [ [('date', '%Y-%m-%d')], [('location', '%country')] ] if hasattr(load_config, 'config'): del load_config.config
def test_get_folder_path_definition_default(): if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() if hasattr(load_config, 'config'): del load_config.config assert path_definition == [[('date', '%Y-%m-%b')], [('album', ''), ('location', '%city'), ('"Unknown Location"', '')]], path_definition
def test_get_folder_path_definition_default(): if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() if hasattr(load_config, 'config'): del load_config.config assert path_definition == filesystem.default_folder_path_definition, path_definition
def test_get_folder_path_definition_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() path_definition = filesystem.get_folder_path_definition() expected = [[('year', '%Y')]] if hasattr(load_config, 'config'): del load_config.config assert path_definition == expected, path_definition
def test_get_folder_path_definition_location_date(): with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: f.write(""" [Directory] date=%Y-%m-%d location=%country full_path=%location/%date """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() expected = [('location', '%country'), ('date', '%Y-%m-%d')] if hasattr(load_config, 'config'): del load_config.config assert path_definition == expected, path_definition
def test_get_folder_path_definition_multi_level_custom(): with open('%s/config.ini-multi-level-custom' % gettempdir(), 'w') as f: f.write(""" [Directory] year=%Y month=%M full_path=%year/%album|%month|%"foo"/%month """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() expected = [[('year', '%Y')], [('album', ''), ('month', '%M'), ('"foo"', '')], [('month', '%M')]] if hasattr(load_config, 'config'): del load_config.config assert path_definition == expected, path_definition
def test_get_folder_path_definition_with_more_than_two_levels(): with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: f.write(""" [Directory] year=%Y month=%m day=%d full_path=%year/%month/%day """) if hasattr(load_config, 'config'): del load_config.config filesystem = FileSystem() path_definition = filesystem.get_folder_path_definition() expected = [[('year', '%Y')], [('month', '%m')], [('day', '%d')]] if hasattr(load_config, 'config'): del load_config.config assert path_definition == expected, path_definition