Changed AlbumInfo and FolderInfo interface to maintain backwards compatibility with PhotosDB.albums
This commit is contained in:
@@ -77,8 +77,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -24,11 +24,7 @@ ALBUM_FOLDER_NAMES_DICT = {
|
||||
"Test Album": [],
|
||||
}
|
||||
|
||||
ALBUM_LEN_DICT = {
|
||||
"Pumpkin Farm": 3,
|
||||
"AlbumInFolder": 2,
|
||||
"Test Album": 1,
|
||||
}
|
||||
ALBUM_LEN_DICT = {"Pumpkin Farm": 3, "AlbumInFolder": 2, "Test Album": 1}
|
||||
|
||||
ALBUM_PHOTO_UUID_DICT = {
|
||||
"Pumpkin Farm": [
|
||||
@@ -46,7 +42,8 @@ ALBUM_PHOTO_UUID_DICT = {
|
||||
],
|
||||
}
|
||||
|
||||
######### Test FolderInfo ##########
|
||||
######### Test FolderInfo ##########
|
||||
|
||||
|
||||
def test_folders_1():
|
||||
import osxphotos
|
||||
@@ -54,20 +51,21 @@ def test_folders_1():
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
folders = photosdb.folder_info
|
||||
assert len(folders) == 1
|
||||
|
||||
# check folder names
|
||||
folder_names = [f.title for f in folders]
|
||||
assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
def test_folder_names():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# check folder names
|
||||
folder_names = photosdb.folder_names
|
||||
folder_names = photosdb.folders
|
||||
assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
@@ -77,7 +75,7 @@ def test_folders_len():
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
folders = photosdb.folder_info
|
||||
assert len(folders[0]) == len(TOP_LEVEL_CHILDREN)
|
||||
|
||||
|
||||
@@ -87,14 +85,14 @@ def test_folders_children():
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
folders = photosdb.folder_info
|
||||
|
||||
# children of top level folder
|
||||
children = folders[0].folders
|
||||
children = folders[0].subfolders
|
||||
children_names = [f.title for f in children]
|
||||
assert sorted(children_names) == sorted(TOP_LEVEL_CHILDREN)
|
||||
|
||||
for child in folders[0].folders:
|
||||
for child in folders[0].subfolders:
|
||||
# check valid children FolderInfo
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folders[0].uuid
|
||||
@@ -110,12 +108,12 @@ def test_folders_parent():
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
folders = photosdb.folder_info
|
||||
|
||||
# parent of top level folder should be none
|
||||
for folder in folders:
|
||||
assert folder.parent is None
|
||||
for child in folder.folders:
|
||||
for child in folder.subfolders:
|
||||
# children's parent uuid should match folder uuid
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folder.uuid
|
||||
@@ -127,25 +125,27 @@ def test_folders_albums():
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
folders = photosdb.folder_info
|
||||
|
||||
for folder in folders:
|
||||
name = folder.title
|
||||
albums = [a.title for a in folder.albums]
|
||||
albums = [a.title for a in folder.album_info]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
for child in folder.folders:
|
||||
for child in folder.subfolders:
|
||||
name = child.title
|
||||
albums = [a.title for a in child.albums]
|
||||
albums = [a.title for a in child.album_info]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
|
||||
########## Test AlbumInfo ##########
|
||||
|
||||
########## Test AlbumInfo ##########
|
||||
|
||||
|
||||
def test_albums_1():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
assert len(albums) == 4
|
||||
|
||||
# check names
|
||||
@@ -158,7 +158,7 @@ def test_albums_parent():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
parent = album.parent.title if album.parent else None
|
||||
@@ -170,7 +170,7 @@ def test_albums_folder_names():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
folder_names = album.folder_names
|
||||
@@ -182,7 +182,7 @@ def test_albums_folders():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
for album in albums:
|
||||
folders = album.folder_list
|
||||
folder_names = [f.title for f in folders]
|
||||
@@ -194,7 +194,7 @@ def test_albums_len():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
assert len(album) == ALBUM_LEN_DICT[album.title]
|
||||
@@ -205,7 +205,7 @@ def test_albums_photos():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
photos = album.photos
|
||||
@@ -213,5 +213,3 @@ def test_albums_photos():
|
||||
assert len(photos) == len(album)
|
||||
for photo in photos:
|
||||
assert photo.uuid in ALBUM_PHOTO_UUID_DICT[album.title]
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,11 @@ ALBUM_LEN_DICT = {
|
||||
}
|
||||
|
||||
ALBUM_PHOTO_UUID_DICT = {
|
||||
"Pumpkin Farm": ["HrK3ZQdlQ7qpDA0FgOYXLA","15uNd7%8RguTEgNPKHfTWw","8SOE9s0XQVGsuq4ONohTng"],
|
||||
"Pumpkin Farm": [
|
||||
"HrK3ZQdlQ7qpDA0FgOYXLA",
|
||||
"15uNd7%8RguTEgNPKHfTWw",
|
||||
"8SOE9s0XQVGsuq4ONohTng",
|
||||
],
|
||||
"Test Album": ["8SOE9s0XQVGsuq4ONohTng"],
|
||||
"Test Album (1)": ["15uNd7%8RguTEgNPKHfTWw"],
|
||||
# "AlbumInFolder": [
|
||||
@@ -62,17 +66,19 @@ def test_folders_1(caplog):
|
||||
# folder_names = [f.title for f in folders]
|
||||
# assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
def test_folder_names(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# check folder names
|
||||
folder_names = photosdb.folder_names
|
||||
folder_names = photosdb.folders
|
||||
assert folder_names == []
|
||||
assert "Folders not yet implemented for this DB version" in caplog.text
|
||||
# assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Folders not yet impleted in Photos < 5")
|
||||
def test_folders_len():
|
||||
import osxphotos
|
||||
@@ -137,11 +143,11 @@ def test_folders_albums():
|
||||
|
||||
for folder in folders:
|
||||
name = folder.title
|
||||
albums = [a.title for a in folder.albums]
|
||||
albums = [a.title for a in folder.album_info]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
for child in folder.folders:
|
||||
name = child.title
|
||||
albums = [a.title for a in child.albums]
|
||||
albums = [a.title for a in child.album_info]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
|
||||
|
||||
@@ -153,7 +159,7 @@ def test_albums_1():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
assert len(albums) == 3
|
||||
|
||||
# check names
|
||||
@@ -166,7 +172,7 @@ def test_albums_parent(caplog):
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
parent = album.parent.title if album.parent else None
|
||||
@@ -179,7 +185,7 @@ def test_albums_folder_names(caplog):
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
folder_names = album.folder_names
|
||||
@@ -192,7 +198,7 @@ def test_albums_folders(caplog):
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
folders = album.folder_list
|
||||
@@ -206,7 +212,7 @@ def test_albums_len():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
assert len(album) == ALBUM_LEN_DICT[album.title]
|
||||
@@ -217,7 +223,7 @@ def test_albums_photos():
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
albums = photosdb.album_info
|
||||
|
||||
for album in albums:
|
||||
photos = album.photos
|
||||
|
||||
@@ -159,8 +159,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -157,8 +157,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -57,7 +57,7 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert photosdb.album_names == []
|
||||
assert photosdb.albums == []
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -76,8 +76,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -76,8 +76,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -84,8 +84,8 @@ def test_album_names():
|
||||
import collections
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
assert "Pumpkin Farm" in photosdb.album_names
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.album_names)
|
||||
assert "Pumpkin Farm" in photosdb.albums
|
||||
assert collections.Counter(ALBUMS) == collections.Counter(photosdb.albums)
|
||||
|
||||
|
||||
def test_keywords_dict():
|
||||
|
||||
@@ -30,7 +30,7 @@ def test_album_names():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
albums = photosdb.album_names
|
||||
albums = photosdb.albums
|
||||
|
||||
assert len(albums) == 1
|
||||
assert albums[0] == ALBUMS[0]
|
||||
@@ -40,7 +40,7 @@ def test_albums_shared():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
albums_shared = photosdb.album_names_shared
|
||||
albums_shared = photosdb.albums_shared
|
||||
|
||||
assert len(albums_shared) == 1
|
||||
assert albums_shared[0] == ALBUMS_SHARED[0]
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_album_names():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
albums = photosdb.album_names
|
||||
albums = photosdb.albums
|
||||
|
||||
assert len(albums) == len(ALBUMS)
|
||||
for album in albums:
|
||||
@@ -26,7 +26,7 @@ def test_albums_names_shared():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
albums_shared = photosdb.album_names_shared
|
||||
albums_shared = photosdb.albums_shared
|
||||
|
||||
assert len(albums_shared) == 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user