def test_process_video_with_album_then_title():
    if not can_edit_exif():
        raise SkipTest('avmetareadwrite executable not found')

    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder, 'movie.mov')
    shutil.copyfile(helper.get_file('video.mov'), origin)

    origin_checksum = helper.checksum(origin)

    media = Video(origin)
    media.set_album('test_album')
    media.set_title('test_title')
    destination = filesystem.process_file(origin,
                                          temporary_folder,
                                          media,
                                          allowDuplicate=True)

    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum != destination_checksum, destination_checksum
    assert helper.path_tz_fix(
        os.path.join('2015-01-Jan', 'test_album',
                     '2015-01-19_12-45-11-movie-test_title.mov')
    ) in destination, destination
Exemple #2
0
def test_import_file_path_utf8_encoded_ascii():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder(
    )

    origin = text_type(folder) + u'/unicode' + six_unichr(
        160) + u'filename.txt'
    # encode the unicode string to ascii
    origin = origin.encode('utf-8')

    shutil.copyfile(helper.get_file('valid.txt'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False,
                                   False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(
        os.path.join(
            '2016-04-Apr', 'London',
            u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.txt')
    ) in dest_path, dest_path
def test_process_file_with_album_and_title_and_location():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder, 'photo.jpg')
    shutil.copyfile(helper.get_file('with-album-and-title-and-location.jpg'),
                    origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin,
                                          temporary_folder,
                                          media,
                                          allowDuplicate=True)

    origin_checksum = helper.checksum(origin)
    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum == destination_checksum, destination_checksum
    assert helper.path_tz_fix(
        os.path.join('2015-12-Dec', 'Test Album',
                     '2015-12-05_00-59-26-photo-some-title.jpg')
    ) in destination, destination
def test_get_file_name_with_title():
    filesystem = FileSystem()
    media = Photo(helper.get_file('with-title.jpg'))
    file_name = filesystem.get_file_name(media)

    assert file_name == helper.path_tz_fix(
        '2015-12-05_00-59-26-with-title-some-title.jpg'), file_name
def test_get_file_name_plain():
    filesystem = FileSystem()
    media = Photo(helper.get_file('plain.jpg'))
    file_name = filesystem.get_file_name(media)

    assert file_name == helper.path_tz_fix(
        '2015-12-05_00-59-26-plain.jpg'), file_name
def test_process_video_with_album_then_title():
    if not can_edit_exif():
        raise SkipTest('avmetareadwrite executable not found')

    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'movie.mov')
    shutil.copyfile(helper.get_file('video.mov'), origin)

    origin_checksum = helper.checksum(origin)

    media = Video(origin)
    media.set_album('test_album')
    media.set_title('test_title')
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum != destination_checksum, destination_checksum
    assert helper.path_tz_fix(os.path.join('2015-01-Jan','test_album','2015-01-19_12-45-11-movie-test_title.mov')) in destination, destination
Exemple #7
0
def test_import_file_video():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = '%s/video.mov' % folder
    shutil.copyfile(helper.get_file('video.mov'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(os.path.join('2015-01-Jan','California','2015-01-19_12-45-11-video.mov')) in dest_path, dest_path
Exemple #8
0
def test_import_file_photo():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = '%s/plain.jpg' % folder
    shutil.copyfile(helper.get_file('plain.jpg'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(os.path.join('2015-12-Dec','Unknown Location','2015-12-05_00-59-26-plain.jpg')) in dest_path, dest_path
Exemple #9
0
def test_import_file_audio():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = '%s/audio.m4a' % folder
    shutil.copyfile(helper.get_file('audio.m4a'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(os.path.join('2016-01-Jan','Houston','2016-01-04_05-28-15-audio.m4a')) in dest_path, dest_path
Exemple #10
0
def test_import_file_text():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = '%s/valid.txt' % folder
    shutil.copyfile(helper.get_file('valid.txt'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(os.path.join('2016-04-Apr','London','2016-04-07_11-15-26-valid-sample-title.txt')) in dest_path, dest_path
Exemple #11
0
def test_import_file_video():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = "%s/video.mov" % folder
    shutil.copyfile(helper.get_file("video.mov"), origin)

    reset_hash_db()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    restore_hash_db()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert (
        helper.path_tz_fix(os.path.join("2015-01-Jan", "California", "2015-01-19_12-45-11-video.mov")) in dest_path
    ), dest_path
Exemple #12
0
def test_import_file_audio():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = "%s/audio.m4a" % folder
    shutil.copyfile(helper.get_file("audio.m4a"), origin)

    reset_hash_db()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    restore_hash_db()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert (
        helper.path_tz_fix(os.path.join("2016-01-Jan", "Houston", "2016-01-04_05-28-15-audio.m4a")) in dest_path
    ), dest_path
Exemple #13
0
def test_import_file_path_unicode():
    raise SkipTest("Temporarily skipping unicode test. sh-167")
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = text_type(folder)+u'/unicode'+six_unichr(160)+u'filename.txt'
    origin = origin.encode('utf-8')

    shutil.copyfile(helper.get_file('valid.txt'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(os.path.join('2016-04-Apr','Unknown Location',u'2016-04-07_11-15-26-unicode\xa0filename-sample-title.txt')) in dest_path, dest_path
Exemple #14
0
def test_import_file_photo():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = "%s/plain.jpg" % folder
    shutil.copyfile(helper.get_file("plain.jpg"), origin)

    reset_hash_db()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    restore_hash_db()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert (
        helper.path_tz_fix(os.path.join("2015-12-Dec", "Unknown Location", "2015-12-05_00-59-26-plain.jpg"))
        in dest_path
    ), dest_path
Exemple #15
0
def test_process_file_with_album_and_title_and_location():
    filesystem = FileSystem()
    temporary_folder, folder = helper.create_working_folder()

    origin = os.path.join(folder,'photo.jpg')
    shutil.copyfile(helper.get_file('with-album-and-title-and-location.jpg'), origin)

    media = Photo(origin)
    destination = filesystem.process_file(origin, temporary_folder, media, allowDuplicate=True)

    origin_checksum = helper.checksum(origin)
    destination_checksum = helper.checksum(destination)

    shutil.rmtree(folder)
    shutil.rmtree(os.path.dirname(os.path.dirname(destination)))

    assert origin_checksum is not None, origin_checksum
    assert origin_checksum == destination_checksum, destination_checksum
    assert helper.path_tz_fix(os.path.join('2015-12-Dec','Test Album','2015-12-05_00-59-26-photo-some-title.jpg')) in destination, destination
Exemple #16
0
def test_import_file_text():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder()

    origin = "%s/valid.txt" % folder
    shutil.copyfile(helper.get_file("valid.txt"), origin)

    reset_hash_db()
    dest_path = elodie.import_file(origin, folder_destination, False, False, False)
    restore_hash_db()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert (
        helper.path_tz_fix(
            os.path.join("2016-04-Apr", "Unknown Location", "2016-04-07_11-15-26-valid-sample-title.txt")
        )
        in dest_path
    ), dest_path
Exemple #17
0
def test_import_file_path_unicode_checkmark():
    temporary_folder, folder = helper.create_working_folder()
    temporary_folder_destination, folder_destination = helper.create_working_folder(
    )

    origin = text_type(folder) + u'/unicode\u2713filename.txt'

    shutil.copyfile(helper.get_file('valid.txt'), origin)

    helper.reset_dbs()
    dest_path = elodie.import_file(origin, folder_destination, False, False,
                                   False)
    helper.restore_dbs()

    shutil.rmtree(folder)
    shutil.rmtree(folder_destination)

    assert helper.path_tz_fix(
        os.path.join(
            '2016-04-Apr', 'London',
            u'2016-04-07_11-15-26-unicode\u2713filename-sample-title.txt')
    ) in dest_path, dest_path
Exemple #18
0
def test_get_file_name_plain():
    filesystem = FileSystem()
    media = Photo(helper.get_file('plain.jpg'))
    file_name = filesystem.get_file_name(media)

    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-plain.jpg'), file_name
Exemple #19
0
def test_get_file_name_with_title():
    filesystem = FileSystem()
    media = Photo(helper.get_file('with-title.jpg'))
    file_name = filesystem.get_file_name(media)

    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-with-title-some-title.jpg'), file_name