|
@@ 568-591 (lines=24) @@
|
| 565 |
|
|
| 566 |
|
assert path == os.path.join('2015','12','No Album Fool','12'), path |
| 567 |
|
|
| 568 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 569 |
|
def test_get_folder_path_with_with_more_than_two_levels(): |
| 570 |
|
with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: |
| 571 |
|
f.write(""" |
| 572 |
|
[MapQuest] |
| 573 |
|
key=czjNKTtFjLydLteUBwdgKAIC8OAbGLUx |
| 574 |
|
|
| 575 |
|
[Directory] |
| 576 |
|
year=%Y |
| 577 |
|
month=%m |
| 578 |
|
location=%city, %state |
| 579 |
|
full_path=%year/%month/%location |
| 580 |
|
""") |
| 581 |
|
|
| 582 |
|
if hasattr(load_config, 'config'): |
| 583 |
|
del load_config.config |
| 584 |
|
|
| 585 |
|
filesystem = FileSystem() |
| 586 |
|
media = Photo(helper.get_file('with-location.jpg')) |
| 587 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 588 |
|
if hasattr(load_config, 'config'): |
| 589 |
|
del load_config.config |
| 590 |
|
|
| 591 |
|
assert path == os.path.join('2015','12','Sunnyvale, California'), path |
| 592 |
|
|
| 593 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 594 |
|
def test_get_folder_path_with_with_only_one_level(): |
|
@@ 526-546 (lines=21) @@
|
| 523 |
|
|
| 524 |
|
assert path == os.path.join('2015-12-Dec','Unknown Location'), path |
| 525 |
|
|
| 526 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-custom-path' % gettempdir()) |
| 527 |
|
def test_get_folder_path_with_custom_path(): |
| 528 |
|
with open('%s/config.ini-custom-path' % gettempdir(), 'w') as f: |
| 529 |
|
f.write(""" |
| 530 |
|
[MapQuest] |
| 531 |
|
key=czjNKTtFjLydLteUBwdgKAIC8OAbGLUx |
| 532 |
|
|
| 533 |
|
[Directory] |
| 534 |
|
date=%Y-%m-%d |
| 535 |
|
location=%country-%state-%city |
| 536 |
|
full_path=%date/%location |
| 537 |
|
""") |
| 538 |
|
if hasattr(load_config, 'config'): |
| 539 |
|
del load_config.config |
| 540 |
|
filesystem = FileSystem() |
| 541 |
|
media = Photo(helper.get_file('with-location.jpg')) |
| 542 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 543 |
|
if hasattr(load_config, 'config'): |
| 544 |
|
del load_config.config |
| 545 |
|
|
| 546 |
|
assert path == os.path.join('2015-12-05','United States of America-California-Sunnyvale'), path |
| 547 |
|
|
| 548 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-fallback' % gettempdir()) |
| 549 |
|
def test_get_folder_path_with_fallback_folder(): |
|
@@ 356-375 (lines=20) @@
|
| 353 |
|
|
| 354 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 355 |
|
|
| 356 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-uppercase' % gettempdir()) |
| 357 |
|
def test_get_file_name_custom_with_upper_capitalization(): |
| 358 |
|
with open('%s/config.ini-filename-custom-with-uppercase' % gettempdir(), 'w') as f: |
| 359 |
|
f.write(""" |
| 360 |
|
[File] |
| 361 |
|
date=%Y-%m-%d |
| 362 |
|
name=%date-%original_name-%title.%extension |
| 363 |
|
capitalization=upper |
| 364 |
|
""") |
| 365 |
|
if hasattr(load_config, 'config'): |
| 366 |
|
del load_config.config |
| 367 |
|
|
| 368 |
|
filesystem = FileSystem() |
| 369 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 370 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 371 |
|
|
| 372 |
|
if hasattr(load_config, 'config'): |
| 373 |
|
del load_config.config |
| 374 |
|
|
| 375 |
|
assert file_name == helper.path_tz_fix('2015-12-05-PLAIN.JPG'), file_name |
| 376 |
|
|
| 377 |
|
def test_get_folder_path_plain(): |
| 378 |
|
filesystem = FileSystem() |
|
@@ 335-354 (lines=20) @@
|
| 332 |
|
|
| 333 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 334 |
|
|
| 335 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-invalidcase' % gettempdir()) |
| 336 |
|
def test_get_file_name_custom_with_invalid_capitalization(): |
| 337 |
|
with open('%s/config.ini-filename-custom-with-invalidcase' % gettempdir(), 'w') as f: |
| 338 |
|
f.write(""" |
| 339 |
|
[File] |
| 340 |
|
date=%Y-%m-%d |
| 341 |
|
name=%date-%original_name-%title.%extension |
| 342 |
|
capitalization=garabage |
| 343 |
|
""") |
| 344 |
|
if hasattr(load_config, 'config'): |
| 345 |
|
del load_config.config |
| 346 |
|
|
| 347 |
|
filesystem = FileSystem() |
| 348 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 349 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 350 |
|
|
| 351 |
|
if hasattr(load_config, 'config'): |
| 352 |
|
del load_config.config |
| 353 |
|
|
| 354 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 355 |
|
|
| 356 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-uppercase' % gettempdir()) |
| 357 |
|
def test_get_file_name_custom_with_upper_capitalization(): |
|
@@ 314-333 (lines=20) @@
|
| 311 |
|
|
| 312 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 313 |
|
|
| 314 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-lowercase' % gettempdir()) |
| 315 |
|
def test_get_file_name_custom_with_lower_capitalization(): |
| 316 |
|
with open('%s/config.ini-filename-custom-with-lowercase' % gettempdir(), 'w') as f: |
| 317 |
|
f.write(""" |
| 318 |
|
[File] |
| 319 |
|
date=%Y-%m-%d |
| 320 |
|
name=%date-%original_name-%title.%extension |
| 321 |
|
capitalization=lower |
| 322 |
|
""") |
| 323 |
|
if hasattr(load_config, 'config'): |
| 324 |
|
del load_config.config |
| 325 |
|
|
| 326 |
|
filesystem = FileSystem() |
| 327 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 328 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 329 |
|
|
| 330 |
|
if hasattr(load_config, 'config'): |
| 331 |
|
del load_config.config |
| 332 |
|
|
| 333 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 334 |
|
|
| 335 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-invalidcase' % gettempdir()) |
| 336 |
|
def test_get_file_name_custom_with_invalid_capitalization(): |
|
@@ 593-611 (lines=19) @@
|
| 590 |
|
|
| 591 |
|
assert path == os.path.join('2015','12','Sunnyvale, California'), path |
| 592 |
|
|
| 593 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-location-date' % gettempdir()) |
| 594 |
|
def test_get_folder_path_with_with_only_one_level(): |
| 595 |
|
with open('%s/config.ini-location-date' % gettempdir(), 'w') as f: |
| 596 |
|
f.write(""" |
| 597 |
|
[Directory] |
| 598 |
|
year=%Y |
| 599 |
|
full_path=%year |
| 600 |
|
""") |
| 601 |
|
|
| 602 |
|
if hasattr(load_config, 'config'): |
| 603 |
|
del load_config.config |
| 604 |
|
|
| 605 |
|
filesystem = FileSystem() |
| 606 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 607 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 608 |
|
if hasattr(load_config, 'config'): |
| 609 |
|
del load_config.config |
| 610 |
|
|
| 611 |
|
assert path == os.path.join('2015'), path |
| 612 |
|
|
| 613 |
|
def test_get_folder_path_with_location_and_title(): |
| 614 |
|
filesystem = FileSystem() |
|
@@ 451-469 (lines=19) @@
|
| 448 |
|
|
| 449 |
|
assert path == os.path.join('2015'), path |
| 450 |
|
|
| 451 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-combined-date-and-album' % gettempdir()) |
| 452 |
|
def test_get_folder_path_with_combined_date_and_album(): |
| 453 |
|
# gh-239 |
| 454 |
|
with open('%s/config.ini-combined-date-and-album' % gettempdir(), 'w') as f: |
| 455 |
|
f.write(""" |
| 456 |
|
[Directory] |
| 457 |
|
date=%Y-%m-%b |
| 458 |
|
custom=%date %album |
| 459 |
|
full_path=%custom |
| 460 |
|
""") |
| 461 |
|
if hasattr(load_config, 'config'): |
| 462 |
|
del load_config.config |
| 463 |
|
filesystem = FileSystem() |
| 464 |
|
media = Photo(helper.get_file('with-album.jpg')) |
| 465 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 466 |
|
if hasattr(load_config, 'config'): |
| 467 |
|
del load_config.config |
| 468 |
|
|
| 469 |
|
assert path == '2015-12-Dec Test Album', path |
| 470 |
|
|
| 471 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-combined-date-album-location-fallback' % gettempdir()) |
| 472 |
|
def test_get_folder_path_with_album_and_location_fallback(): |
|
@@ 294-312 (lines=19) @@
|
| 291 |
|
|
| 292 |
|
assert file_name == helper.path_tz_fix('2015-12-05-with-title-some-title.jpg'), file_name |
| 293 |
|
|
| 294 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-empty-value' % gettempdir()) |
| 295 |
|
def test_get_file_name_custom_with_empty_value(): |
| 296 |
|
with open('%s/config.ini-filename-custom-with-empty-value' % gettempdir(), 'w') as f: |
| 297 |
|
f.write(""" |
| 298 |
|
[File] |
| 299 |
|
date=%Y-%m-%d |
| 300 |
|
name=%date-%original_name-%title.%extension |
| 301 |
|
""") |
| 302 |
|
if hasattr(load_config, 'config'): |
| 303 |
|
del load_config.config |
| 304 |
|
|
| 305 |
|
filesystem = FileSystem() |
| 306 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 307 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 308 |
|
|
| 309 |
|
if hasattr(load_config, 'config'): |
| 310 |
|
del load_config.config |
| 311 |
|
|
| 312 |
|
assert file_name == helper.path_tz_fix('2015-12-05-plain.jpg'), file_name |
| 313 |
|
|
| 314 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-lowercase' % gettempdir()) |
| 315 |
|
def test_get_file_name_custom_with_lower_capitalization(): |
|
@@ 274-292 (lines=19) @@
|
| 271 |
|
|
| 272 |
|
assert file_name == helper.path_tz_fix('2015-12-dec-plain.jpg'), file_name |
| 273 |
|
|
| 274 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-title' % gettempdir()) |
| 275 |
|
def test_get_file_name_custom_with_title(): |
| 276 |
|
with open('%s/config.ini-filename-custom-with-title' % gettempdir(), 'w') as f: |
| 277 |
|
f.write(""" |
| 278 |
|
[File] |
| 279 |
|
date=%Y-%m-%d |
| 280 |
|
name=%date-%original_name-%title.%extension |
| 281 |
|
""") |
| 282 |
|
if hasattr(load_config, 'config'): |
| 283 |
|
del load_config.config |
| 284 |
|
|
| 285 |
|
filesystem = FileSystem() |
| 286 |
|
media = Photo(helper.get_file('with-title.jpg')) |
| 287 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 288 |
|
|
| 289 |
|
if hasattr(load_config, 'config'): |
| 290 |
|
del load_config.config |
| 291 |
|
|
| 292 |
|
assert file_name == helper.path_tz_fix('2015-12-05-with-title-some-title.jpg'), file_name |
| 293 |
|
|
| 294 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-empty-value' % gettempdir()) |
| 295 |
|
def test_get_file_name_custom_with_empty_value(): |
|
@@ 254-272 (lines=19) @@
|
| 251 |
|
|
| 252 |
|
assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-plain-with-spaces-and-uppercase-123.jpg'), file_name |
| 253 |
|
|
| 254 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom' % gettempdir()) |
| 255 |
|
def test_get_file_name_custom(): |
| 256 |
|
with open('%s/config.ini-filename-custom' % gettempdir(), 'w') as f: |
| 257 |
|
f.write(""" |
| 258 |
|
[File] |
| 259 |
|
date=%Y-%m-%b |
| 260 |
|
name=%date-%original_name.%extension |
| 261 |
|
""") |
| 262 |
|
if hasattr(load_config, 'config'): |
| 263 |
|
del load_config.config |
| 264 |
|
|
| 265 |
|
filesystem = FileSystem() |
| 266 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 267 |
|
file_name = filesystem.get_file_name(media.get_metadata()) |
| 268 |
|
|
| 269 |
|
if hasattr(load_config, 'config'): |
| 270 |
|
del load_config.config |
| 271 |
|
|
| 272 |
|
assert file_name == helper.path_tz_fix('2015-12-dec-plain.jpg'), file_name |
| 273 |
|
|
| 274 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-filename-custom-with-title' % gettempdir()) |
| 275 |
|
def test_get_file_name_custom_with_title(): |
|
@@ 432-449 (lines=18) @@
|
| 429 |
|
|
| 430 |
|
assert path == os.path.join('nomake', 'nomodel'), path |
| 431 |
|
|
| 432 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-int-in-component-path' % gettempdir()) |
| 433 |
|
def test_get_folder_path_with_int_in_config_component(): |
| 434 |
|
# gh-239 |
| 435 |
|
with open('%s/config.ini-int-in-component-path' % gettempdir(), 'w') as f: |
| 436 |
|
f.write(""" |
| 437 |
|
[Directory] |
| 438 |
|
date=%Y |
| 439 |
|
full_path=%date |
| 440 |
|
""") |
| 441 |
|
if hasattr(load_config, 'config'): |
| 442 |
|
del load_config.config |
| 443 |
|
filesystem = FileSystem() |
| 444 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 445 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 446 |
|
if hasattr(load_config, 'config'): |
| 447 |
|
del load_config.config |
| 448 |
|
|
| 449 |
|
assert path == os.path.join('2015'), path |
| 450 |
|
|
| 451 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-combined-date-and-album' % gettempdir()) |
| 452 |
|
def test_get_folder_path_with_combined_date_and_album(): |
|
@@ 415-430 (lines=16) @@
|
| 412 |
|
|
| 413 |
|
assert path == os.path.join('Canon', 'Canon EOS REBEL T2i'), path |
| 414 |
|
|
| 415 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-original-with-camera-make-and-model-fallback' % gettempdir()) |
| 416 |
|
def test_get_folder_path_with_camera_make_and_model_fallback(): |
| 417 |
|
with open('%s/config.ini-original-with-camera-make-and-model-fallback' % gettempdir(), 'w') as f: |
| 418 |
|
f.write(""" |
| 419 |
|
[Directory] |
| 420 |
|
full_path=%camera_make|"nomake"/%camera_model|"nomodel" |
| 421 |
|
""") |
| 422 |
|
if hasattr(load_config, 'config'): |
| 423 |
|
del load_config.config |
| 424 |
|
filesystem = FileSystem() |
| 425 |
|
media = Photo(helper.get_file('no-exif.jpg')) |
| 426 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 427 |
|
if hasattr(load_config, 'config'): |
| 428 |
|
del load_config.config |
| 429 |
|
|
| 430 |
|
assert path == os.path.join('nomake', 'nomodel'), path |
| 431 |
|
|
| 432 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-int-in-component-path' % gettempdir()) |
| 433 |
|
def test_get_folder_path_with_int_in_config_component(): |
|
@@ 398-413 (lines=16) @@
|
| 395 |
|
|
| 396 |
|
assert path == os.path.join('2015-12-Dec','Sunnyvale'), path |
| 397 |
|
|
| 398 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-original-with-camera-make-and-model' % gettempdir()) |
| 399 |
|
def test_get_folder_path_with_camera_make_and_model(): |
| 400 |
|
with open('%s/config.ini-original-with-camera-make-and-model' % gettempdir(), 'w') as f: |
| 401 |
|
f.write(""" |
| 402 |
|
[Directory] |
| 403 |
|
full_path=%camera_make/%camera_model |
| 404 |
|
""") |
| 405 |
|
if hasattr(load_config, 'config'): |
| 406 |
|
del load_config.config |
| 407 |
|
filesystem = FileSystem() |
| 408 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 409 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 410 |
|
if hasattr(load_config, 'config'): |
| 411 |
|
del load_config.config |
| 412 |
|
|
| 413 |
|
assert path == os.path.join('Canon', 'Canon EOS REBEL T2i'), path |
| 414 |
|
|
| 415 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-original-with-camera-make-and-model-fallback' % gettempdir()) |
| 416 |
|
def test_get_folder_path_with_camera_make_and_model_fallback(): |
|
@@ 512-524 (lines=13) @@
|
| 509 |
|
|
| 510 |
|
assert path == os.path.join('2015-12-Dec','Unknown Location'), path |
| 511 |
|
|
| 512 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-original-default-unknown-location' % gettempdir()) |
| 513 |
|
def test_get_folder_path_with_original_default_unknown_location(): |
| 514 |
|
with open('%s/config.ini-original-default-with-unknown-location' % gettempdir(), 'w') as f: |
| 515 |
|
f.write('') |
| 516 |
|
if hasattr(load_config, 'config'): |
| 517 |
|
del load_config.config |
| 518 |
|
filesystem = FileSystem() |
| 519 |
|
media = Photo(helper.get_file('plain.jpg')) |
| 520 |
|
path = filesystem.get_folder_path(media.get_metadata()) |
| 521 |
|
if hasattr(load_config, 'config'): |
| 522 |
|
del load_config.config |
| 523 |
|
|
| 524 |
|
assert path == os.path.join('2015-12-Dec','Unknown Location'), path |
| 525 |
|
|
| 526 |
|
@mock.patch('elodie.config.config_file', '%s/config.ini-custom-path' % gettempdir()) |
| 527 |
|
def test_get_folder_path_with_custom_path(): |