Code Duplication    Length = 20-22 lines in 5 locations

elodie/tests/filesystem_test.py 5 locations

@@ 1221-1242 (lines=22) @@
1218
    if hasattr(load_config, 'config'):
1219
        del load_config.config
1220
1221
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir())
1222
def test_get_folder_path_definition_with_more_than_two_levels():
1223
    with open('%s/config.ini-location-date' % gettempdir(), 'w') as f:
1224
        f.write("""
1225
[Directory]
1226
year=%Y
1227
month=%m
1228
day=%d
1229
full_path=%year/%month/%day
1230
        """)
1231
1232
    if hasattr(load_config, 'config'):
1233
        del load_config.config
1234
    filesystem = FileSystem()
1235
    path_definition = filesystem.get_folder_path_definition()
1236
    expected = [
1237
        [('year', '%Y')], [('month', '%m')], [('day', '%d')]
1238
    ]
1239
    if hasattr(load_config, 'config'):
1240
        del load_config.config
1241
1242
    assert path_definition == expected, path_definition
1243
1244
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir())
1245
def test_get_folder_path_definition_with_only_one_level():
@@ 1162-1182 (lines=21) @@
1159
1160
    assert path_definition == expected, path_definition
1161
1162
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir())
1163
def test_get_folder_path_definition_location_date():
1164
    with open('%s/config.ini-location-date' % gettempdir(), 'w') as f:
1165
        f.write("""
1166
[Directory]
1167
date=%Y-%m-%d
1168
location=%country
1169
full_path=%location/%date
1170
        """)
1171
1172
    if hasattr(load_config, 'config'):
1173
        del load_config.config
1174
    filesystem = FileSystem()
1175
    path_definition = filesystem.get_folder_path_definition()
1176
    expected = [
1177
        [('location', '%country')], [('date', '%Y-%m-%d')]
1178
    ]
1179
    if hasattr(load_config, 'config'):
1180
        del load_config.config
1181
1182
    assert path_definition == expected, path_definition
1183
1184
@mock.patch('elodie.config.config_file', '%s/config.ini-cached' % gettempdir())
1185
def test_get_folder_path_definition_cached():
@@ 1140-1160 (lines=21) @@
1137
1138
    assert path_definition == [[('date', '%Y-%m-%b')], [('album', ''), ('location', '%city'), ('"Unknown Location"', '')]], path_definition
1139
1140
@mock.patch('elodie.config.config_file', '%s/config.ini-date-location' % gettempdir())
1141
def test_get_folder_path_definition_date_location():
1142
    with open('%s/config.ini-date-location' % gettempdir(), 'w') as f:
1143
        f.write("""
1144
[Directory]
1145
date=%Y-%m-%d
1146
location=%country
1147
full_path=%date/%location
1148
        """)
1149
1150
    if hasattr(load_config, 'config'):
1151
        del load_config.config
1152
    filesystem = FileSystem()
1153
    path_definition = filesystem.get_folder_path_definition()
1154
    expected = [
1155
        [('date', '%Y-%m-%d')], [('location', '%country')]
1156
    ]
1157
    if hasattr(load_config, 'config'):
1158
        del load_config.config
1159
1160
    assert path_definition == expected, path_definition
1161
1162
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir())
1163
def test_get_folder_path_definition_location_date():
@@ 1265-1284 (lines=20) @@
1262
1263
    assert path_definition == expected, path_definition
1264
1265
@mock.patch('elodie.config.config_file', '%s/config.ini-multi-level-custom' % gettempdir())
1266
def test_get_folder_path_definition_multi_level_custom():
1267
    with open('%s/config.ini-multi-level-custom' % gettempdir(), 'w') as f:
1268
        f.write("""
1269
[Directory]
1270
year=%Y
1271
month=%M
1272
full_path=%year/%album|%month|%"foo"/%month
1273
        """)
1274
1275
    if hasattr(load_config, 'config'):
1276
        del load_config.config
1277
    filesystem = FileSystem()
1278
    path_definition = filesystem.get_folder_path_definition()
1279
    
1280
    expected = [[('year', '%Y')], [('album', ''), ('month', '%M'), ('"foo"', '')], [('month', '%M')]]
1281
    if hasattr(load_config, 'config'):
1282
        del load_config.config
1283
1284
    assert path_definition == expected, path_definition
1285
@@ 1244-1263 (lines=20) @@
1241
1242
    assert path_definition == expected, path_definition
1243
1244
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir())
1245
def test_get_folder_path_definition_with_only_one_level():
1246
    with open('%s/config.ini-location-date' % gettempdir(), 'w') as f:
1247
        f.write("""
1248
[Directory]
1249
year=%Y
1250
full_path=%year
1251
        """)
1252
1253
    if hasattr(load_config, 'config'):
1254
        del load_config.config
1255
    filesystem = FileSystem()
1256
    path_definition = filesystem.get_folder_path_definition()
1257
    expected = [
1258
        [('year', '%Y')]
1259
    ]
1260
    if hasattr(load_config, 'config'):
1261
        del load_config.config
1262
1263
    assert path_definition == expected, path_definition
1264
1265
@mock.patch('elodie.config.config_file', '%s/config.ini-multi-level-custom' % gettempdir())
1266
def test_get_folder_path_definition_multi_level_custom():