示例#1
0
def test_has_album():
    photo = Photo(helper.get_file('with-album.jpg'))
    album = photo.get_album()

    assert album == 'Test Album', album
示例#2
0
def test_is_valid():
    photo = Photo(helper.get_file('plain.jpg'))

    assert photo.is_valid()
示例#3
0
def test_pillow_not_loaded():
    photo = Photo(helper.get_file('imghdr-error.jpg'))
    photo.pillow = None

    assert photo.is_valid() == False
示例#4
0
def test_empty_album():
    photo = Photo(helper.get_file('plain.jpg'))
    assert photo.get_album() is None
示例#5
0
def test_get_folder_path_with_title():
    filesystem = FileSystem()
    media = Photo(helper.get_file('with-title.jpg'))
    path = filesystem.get_folder_path(media.get_metadata())

    assert path == os.path.join('2015-12-Dec', 'Unknown Location'), path
示例#6
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.get_metadata())

    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-with-title-some-title.jpg'), file_name
示例#7
0
def test_get_camera_model():
    photo = Photo(helper.get_file('with-location.jpg'))
    model = photo.get_camera_model()

    assert model == 'Canon EOS REBEL T2i', model
示例#8
0
def test_get_coordinate_default():
    photo = Photo(helper.get_file('with-location.jpg'))
    coordinate = photo.get_coordinate()

    assert helper.isclose(coordinate, 37.3667027222), coordinate
示例#9
0
def test_get_camera_make():
    photo = Photo(helper.get_file('with-location.jpg'))
    make = photo.get_camera_make()

    assert make == 'Canon', make
示例#10
0
def test_get_camera_make_not_set():
    photo = Photo(helper.get_file('no-exif.jpg'))
    make = photo.get_camera_make()

    assert make is None, make
示例#11
0
def test_get_coordinate_longitude_plus():
    photo = Photo(helper.get_file('with-location-inv.jpg'))
    coordinate = photo.get_coordinate('longitude')

    assert helper.isclose(coordinate, 122.033383611), coordinate
示例#12
0
def test_get_file_name_with_uppercase_and_spaces():
    filesystem = FileSystem()
    media = Photo(helper.get_file('Plain With Spaces And Uppercase 123.jpg'))
    file_name = filesystem.get_file_name(media.get_metadata())

    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-plain-with-spaces-and-uppercase-123.jpg'), file_name
示例#13
0
def test_get_file_name_with_original_name_title_exif():
    filesystem = FileSystem()
    media = Photo(helper.get_file('with-filename-and-title-in-exif.jpg'))
    file_name = filesystem.get_file_name(media.get_metadata())

    assert file_name == helper.path_tz_fix('2015-12-05_00-59-26-foobar-foobar-title.jpg'), file_name
示例#14
0
def test_is_not_valid():
    photo = Photo(helper.get_file('text.txt'))

    assert not photo.is_valid()
示例#15
0
def test_get_camera_model_not_set():
    photo = Photo(helper.get_file('no-exif.jpg'))
    model = photo.get_camera_model()

    assert model is None, model
示例#16
0
def test_get_metadata_of_invalid_photo():
    photo = Photo(helper.get_file('invalid.jpg'))
    metadata = photo.get_metadata()

    assert metadata is None
示例#17
0
def test_is_valid():
    photo = Photo(helper.get_file('with-location.jpg'))

    assert photo.is_valid()
示例#18
0
def test_get_coordinate_latitude_minus():
    photo = Photo(helper.get_file('with-location-inv.jpg'))
    coordinate = photo.get_coordinate('latitude')

    assert helper.isclose(coordinate, -37.3667027222), coordinate
示例#19
0
def test_is_valid_fallback_using_pillow():
    photo = Photo(helper.get_file('imghdr-error.jpg'))

    assert photo.is_valid()
示例#20
0
def test_get_folder_path_with_location():
    filesystem = FileSystem()
    media = Photo(helper.get_file('with-location.jpg'))
    path = filesystem.get_folder_path(media.get_metadata())

    assert path == os.path.join('2015-12-Dec', 'Sunnyvale'), path
示例#21
0
def test_get_file_name_plain():
    filesystem = FileSystem()
    media = Photo(helper.get_file('plain.jpg'))
    file_name = filesystem.get_file_name(media.get_metadata())

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