コード例 #1
0
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
    destination_folder = DestinationFolder()
    path_definition = destination_folder.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
    destination_folder = DestinationFolder()
    path_definition = destination_folder.get_folder_path_definition()
    expected = [[('date', '%Y-%m-%d')], [('location', '%country')]]
    if hasattr(load_config, 'config'):
        del load_config.config
コード例 #2
0
def test_get_folder_path_definition_default():
    if hasattr(load_config, 'config'):
        del load_config.config
    destination_folder = DestinationFolder()
    path_definition = destination_folder.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
コード例 #3
0
def test_get_folder_path_definition_multi_level_location_definition():
    with open('%s/config.ini-multi_level_location' % gettempdir(), 'w') as f:
        f.write(multi_level_location_config_json)

    mock_location_db(mock_location_db_json_txt)

    if hasattr(load_config, 'config'):
        del load_config.config
    destination_folder = DestinationFolder()
    path_definition = destination_folder.get_folder_path_definition()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert path_definition == multi_level_location_definition_CCCV, path_definition
コード例 #4
0
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
    destination_folder = DestinationFolder()
    path_definition = destination_folder.get_folder_path_definition()
    expected = [[('year', '%Y')]]
    if hasattr(load_config, 'config'):
        del load_config.config

    assert path_definition == expected, path_definition
コード例 #5
0
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
    destination_folder = DestinationFolder()
    path_definition = destination_folder.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
コード例 #6
0
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
    destination_folder = DestinationFolder()
    path_definition = destination_folder.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