|
@@ 1263-1284 (lines=22) @@
|
| 1260 |
|
if hasattr(load_config, 'config'): |
| 1261 |
|
del load_config.config |
| 1262 |
|
|
| 1263 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 1264 |
|
def test_get_folder_path_definition_with_more_than_two_levels(): |
| 1265 |
|
with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: |
| 1266 |
|
f.write(""" |
| 1267 |
|
[Directory] |
| 1268 |
|
year=%Y |
| 1269 |
|
month=%m |
| 1270 |
|
day=%d |
| 1271 |
|
full_path=%year/%month/%day |
| 1272 |
|
""") |
| 1273 |
|
|
| 1274 |
|
if hasattr(load_config, 'config'): |
| 1275 |
|
del load_config.config |
| 1276 |
|
filesystem = FileSystem() |
| 1277 |
|
path_definition = filesystem.get_folder_path_definition() |
| 1278 |
|
expected = [ |
| 1279 |
|
[('year', '%Y')], [('month', '%m')], [('day', '%d')] |
| 1280 |
|
] |
| 1281 |
|
if hasattr(load_config, 'config'): |
| 1282 |
|
del load_config.config |
| 1283 |
|
|
| 1284 |
|
assert path_definition == expected, path_definition |
| 1285 |
|
|
| 1286 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 1287 |
|
def test_get_folder_path_definition_with_only_one_level(): |
|
@@ 1204-1224 (lines=21) @@
|
| 1201 |
|
|
| 1202 |
|
assert path_definition == expected, path_definition |
| 1203 |
|
|
| 1204 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 1205 |
|
def test_get_folder_path_definition_location_date(): |
| 1206 |
|
with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: |
| 1207 |
|
f.write(""" |
| 1208 |
|
[Directory] |
| 1209 |
|
date=%Y-%m-%d |
| 1210 |
|
location=%country |
| 1211 |
|
full_path=%location/%date |
| 1212 |
|
""") |
| 1213 |
|
|
| 1214 |
|
if hasattr(load_config, 'config'): |
| 1215 |
|
del load_config.config |
| 1216 |
|
filesystem = FileSystem() |
| 1217 |
|
path_definition = filesystem.get_folder_path_definition() |
| 1218 |
|
expected = [ |
| 1219 |
|
[('location', '%country')], [('date', '%Y-%m-%d')] |
| 1220 |
|
] |
| 1221 |
|
if hasattr(load_config, 'config'): |
| 1222 |
|
del load_config.config |
| 1223 |
|
|
| 1224 |
|
assert path_definition == expected, path_definition |
| 1225 |
|
|
| 1226 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-cached' % gettempdir()) |
| 1227 |
|
def test_get_folder_path_definition_cached(): |
|
@@ 1182-1202 (lines=21) @@
|
| 1179 |
|
|
| 1180 |
|
assert path_definition == [[('date', '%Y-%m-%b')], [('album', ''), ('location', '%city'), ('"Unknown Location"', '')]], path_definition |
| 1181 |
|
|
| 1182 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-date-location' % gettempdir()) |
| 1183 |
|
def test_get_folder_path_definition_date_location(): |
| 1184 |
|
with open('%s/config.ini-date-location' % gettempdir(), 'w') as f: |
| 1185 |
|
f.write(""" |
| 1186 |
|
[Directory] |
| 1187 |
|
date=%Y-%m-%d |
| 1188 |
|
location=%country |
| 1189 |
|
full_path=%date/%location |
| 1190 |
|
""") |
| 1191 |
|
|
| 1192 |
|
if hasattr(load_config, 'config'): |
| 1193 |
|
del load_config.config |
| 1194 |
|
filesystem = FileSystem() |
| 1195 |
|
path_definition = filesystem.get_folder_path_definition() |
| 1196 |
|
expected = [ |
| 1197 |
|
[('date', '%Y-%m-%d')], [('location', '%country')] |
| 1198 |
|
] |
| 1199 |
|
if hasattr(load_config, 'config'): |
| 1200 |
|
del load_config.config |
| 1201 |
|
|
| 1202 |
|
assert path_definition == expected, path_definition |
| 1203 |
|
|
| 1204 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 1205 |
|
def test_get_folder_path_definition_location_date(): |
|
@@ 1307-1326 (lines=20) @@
|
| 1304 |
|
|
| 1305 |
|
assert path_definition == expected, path_definition |
| 1306 |
|
|
| 1307 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-multi-level-custom' % gettempdir()) |
| 1308 |
|
def test_get_folder_path_definition_multi_level_custom(): |
| 1309 |
|
with open('%s/config.ini-multi-level-custom' % gettempdir(), 'w') as f: |
| 1310 |
|
f.write(""" |
| 1311 |
|
[Directory] |
| 1312 |
|
year=%Y |
| 1313 |
|
month=%M |
| 1314 |
|
full_path=%year/%album|%month|%"foo"/%month |
| 1315 |
|
""") |
| 1316 |
|
|
| 1317 |
|
if hasattr(load_config, 'config'): |
| 1318 |
|
del load_config.config |
| 1319 |
|
filesystem = FileSystem() |
| 1320 |
|
path_definition = filesystem.get_folder_path_definition() |
| 1321 |
|
|
| 1322 |
|
expected = [[('year', '%Y')], [('album', ''), ('month', '%M'), ('"foo"', '')], [('month', '%M')]] |
| 1323 |
|
if hasattr(load_config, 'config'): |
| 1324 |
|
del load_config.config |
| 1325 |
|
|
| 1326 |
|
assert path_definition == expected, path_definition |
| 1327 |
|
|
|
@@ 1286-1305 (lines=20) @@
|
| 1283 |
|
|
| 1284 |
|
assert path_definition == expected, path_definition |
| 1285 |
|
|
| 1286 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 1287 |
|
def test_get_folder_path_definition_with_only_one_level(): |
| 1288 |
|
with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: |
| 1289 |
|
f.write(""" |
| 1290 |
|
[Directory] |
| 1291 |
|
year=%Y |
| 1292 |
|
full_path=%year |
| 1293 |
|
""") |
| 1294 |
|
|
| 1295 |
|
if hasattr(load_config, 'config'): |
| 1296 |
|
del load_config.config |
| 1297 |
|
filesystem = FileSystem() |
| 1298 |
|
path_definition = filesystem.get_folder_path_definition() |
| 1299 |
|
expected = [ |
| 1300 |
|
[('year', '%Y')] |
| 1301 |
|
] |
| 1302 |
|
if hasattr(load_config, 'config'): |
| 1303 |
|
del load_config.config |
| 1304 |
|
|
| 1305 |
|
assert path_definition == expected, path_definition |
| 1306 |
|
|
| 1307 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-multi-level-custom' % gettempdir()) |
| 1308 |
|
def test_get_folder_path_definition_multi_level_custom(): |