Added tests and README for AlbumInfo and FolderInfo
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@
|
||||
<key>hostuuid</key>
|
||||
<string>9575E48B-8D5F-5654-ABAC-4431B1167324</string>
|
||||
<key>pid</key>
|
||||
<integer>1440</integer>
|
||||
<integer>3212</integer>
|
||||
<key>processname</key>
|
||||
<string>photolibraryd</string>
|
||||
<key>uid</key>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,9 @@
|
||||
<array/>
|
||||
<key>ExpandedSidebarItemIdentifiers</key>
|
||||
<array>
|
||||
<string>88A5F8B8-5B9A-43C7-BB85-3952B81580EB/L0/020</string>
|
||||
<string>92D68107-B6C7-453B-96D2-97B0F26D5B8B/L0/020</string>
|
||||
<string>29EF7A97-7E76-4D5F-A5E0-CC0A93E8524C/L0/020</string>
|
||||
</array>
|
||||
<key>Photos</key>
|
||||
<dict>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,24 +3,24 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BackgroundHighlightCollection</key>
|
||||
<date>2020-04-04T17:34:35Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>BackgroundHighlightEnrichment</key>
|
||||
<date>2020-04-04T17:34:34Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>BackgroundJobAssetRevGeocode</key>
|
||||
<date>2020-04-04T20:16:33Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>BackgroundJobSearch</key>
|
||||
<date>2020-04-04T17:34:35Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>BackgroundPeopleSuggestion</key>
|
||||
<date>2020-04-04T17:34:34Z</date>
|
||||
<date>2020-04-11T20:00:24Z</date>
|
||||
<key>BackgroundUserBehaviorProcessor</key>
|
||||
<date>2020-04-04T13:56:56Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>PhotoAnalysisGraphLastBackgroundGraphConsistencyUpdateJobDateKey</key>
|
||||
<date>2020-04-04T20:16:40Z</date>
|
||||
<date>2020-04-11T20:10:27Z</date>
|
||||
<key>PhotoAnalysisGraphLastBackgroundGraphRebuildJobDate</key>
|
||||
<date>2020-04-04T13:56:49Z</date>
|
||||
<date>2020-04-11T20:00:24Z</date>
|
||||
<key>PhotoAnalysisGraphLastBackgroundMemoryGenerationJobDate</key>
|
||||
<date>2020-04-04T20:16:33Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>SiriPortraitDonation</key>
|
||||
<date>2020-04-04T13:56:56Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,8 +3,8 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>FaceIDModelLastGenerationKey</key>
|
||||
<date>2020-04-04T13:56:59Z</date>
|
||||
<date>2020-04-11T20:00:25Z</date>
|
||||
<key>LastContactClassificationKey</key>
|
||||
<date>2020-04-04T13:57:02Z</date>
|
||||
<date>2020-04-11T20:00:26Z</date>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>coalesceDate</key>
|
||||
<date>2019-12-08T18:06:37Z</date>
|
||||
<date>2020-04-11T19:26:12Z</date>
|
||||
<key>coalescePayloadVersion</key>
|
||||
<integer>1</integer>
|
||||
<key>currentPayloadVersion</key>
|
||||
|
||||
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>coalesceDate</key>
|
||||
<date>2019-12-08T18:06:37Z</date>
|
||||
<date>2020-04-11T19:26:12Z</date>
|
||||
<key>coalescePayloadVersion</key>
|
||||
<integer>1</integer>
|
||||
<key>currentPayloadVersion</key>
|
||||
|
||||
Binary file not shown.
217
tests/test_albums_folders_catalina_10_15_4.py
Normal file
217
tests/test_albums_folders_catalina_10_15_4.py
Normal file
@@ -0,0 +1,217 @@
|
||||
import pytest
|
||||
|
||||
from osxphotos._constants import _UNKNOWN_PERSON
|
||||
|
||||
PHOTOS_DB = "./tests/Test-10.15.4.photoslibrary/database/photos.db"
|
||||
|
||||
TOP_LEVEL_FOLDERS = ["Folder1"]
|
||||
|
||||
TOP_LEVEL_CHILDREN = ["SubFolder1", "SubFolder2"]
|
||||
|
||||
FOLDER_ALBUM_DICT = {"Folder1": [], "SubFolder1": [], "SubFolder2": ["AlbumInFolder"]}
|
||||
|
||||
ALBUM_NAMES = ["Pumpkin Farm", "AlbumInFolder", "Test Album", "Test Album"]
|
||||
|
||||
ALBUM_PARENT_DICT = {
|
||||
"Pumpkin Farm": None,
|
||||
"AlbumInFolder": "SubFolder2",
|
||||
"Test Album": None,
|
||||
}
|
||||
|
||||
ALBUM_FOLDER_NAMES_DICT = {
|
||||
"Pumpkin Farm": [],
|
||||
"AlbumInFolder": ["Folder1", "SubFolder2"],
|
||||
"Test Album": [],
|
||||
}
|
||||
|
||||
ALBUM_LEN_DICT = {
|
||||
"Pumpkin Farm": 3,
|
||||
"AlbumInFolder": 2,
|
||||
"Test Album": 1,
|
||||
}
|
||||
|
||||
ALBUM_PHOTO_UUID_DICT = {
|
||||
"Pumpkin Farm": [
|
||||
"F12384F6-CD17-4151-ACBA-AE0E3688539E",
|
||||
"D79B8D77-BFFC-460B-9312-034F2877D35B",
|
||||
"1EB2B765-0765-43BA-A90C-0D0580E6172C",
|
||||
],
|
||||
"Test Album": [
|
||||
"F12384F6-CD17-4151-ACBA-AE0E3688539E",
|
||||
"D79B8D77-BFFC-460B-9312-034F2877D35B",
|
||||
],
|
||||
"AlbumInFolder": [
|
||||
"3DD2C897-F19E-4CA6-8C22-B027D5A71907",
|
||||
"E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51",
|
||||
],
|
||||
}
|
||||
|
||||
######### Test FolderInfo ##########
|
||||
|
||||
def test_folders_1():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
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
|
||||
assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
def test_folders_len():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
assert len(folders[0]) == len(TOP_LEVEL_CHILDREN)
|
||||
|
||||
|
||||
def test_folders_children():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
# children of top level folder
|
||||
children = folders[0].folders
|
||||
children_names = [f.title for f in children]
|
||||
assert sorted(children_names) == sorted(TOP_LEVEL_CHILDREN)
|
||||
|
||||
for child in folders[0].folders:
|
||||
# check valid children FolderInfo
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folders[0].uuid
|
||||
|
||||
# check folder names
|
||||
folder_names = [f.title for f in folders]
|
||||
assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
def test_folders_parent():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
# parent of top level folder should be none
|
||||
for folder in folders:
|
||||
assert folder.parent is None
|
||||
for child in folder.folders:
|
||||
# children's parent uuid should match folder uuid
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folder.uuid
|
||||
|
||||
|
||||
def test_folders_albums():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
for folder in folders:
|
||||
name = folder.title
|
||||
albums = [a.title for a in folder.albums]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
for child in folder.folders:
|
||||
name = child.title
|
||||
albums = [a.title for a in child.albums]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
|
||||
########## Test AlbumInfo ##########
|
||||
|
||||
def test_albums_1():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
assert len(albums) == 4
|
||||
|
||||
# check names
|
||||
album_names = [a.title for a in albums]
|
||||
assert sorted(album_names) == sorted(ALBUM_NAMES)
|
||||
|
||||
|
||||
def test_albums_parent():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
parent = album.parent.title if album.parent else None
|
||||
assert parent == ALBUM_PARENT_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_folder_names():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
folder_names = album.folder_names
|
||||
assert folder_names == ALBUM_FOLDER_NAMES_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_folders():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
for album in albums:
|
||||
folders = album.folder_list
|
||||
folder_names = [f.title for f in folders]
|
||||
assert folder_names == ALBUM_FOLDER_NAMES_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_len():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
assert len(album) == ALBUM_LEN_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_photos():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
photos = album.photos
|
||||
assert len(photos) == ALBUM_LEN_DICT[album.title]
|
||||
assert len(photos) == len(album)
|
||||
for photo in photos:
|
||||
assert photo.uuid in ALBUM_PHOTO_UUID_DICT[album.title]
|
||||
|
||||
|
||||
227
tests/test_albums_folders_mojave_10_14_6.py
Normal file
227
tests/test_albums_folders_mojave_10_14_6.py
Normal file
@@ -0,0 +1,227 @@
|
||||
import pytest
|
||||
|
||||
from osxphotos._constants import _UNKNOWN_PERSON
|
||||
|
||||
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
||||
|
||||
# TOP_LEVEL_FOLDERS = ["Folder1"]
|
||||
|
||||
# TOP_LEVEL_CHILDREN = ["SubFolder1", "SubFolder2"]
|
||||
|
||||
# FOLDER_ALBUM_DICT = {"Folder1": [], "SubFolder1": [], "SubFolder2": ["AlbumInFolder"]}
|
||||
|
||||
# ALBUM_NAMES = ["Pumpkin Farm", "AlbumInFolder", "Test Album", "Test Album"]
|
||||
ALBUM_NAMES = ["Pumpkin Farm", "Test Album", "Test Album (1)"]
|
||||
|
||||
# ALBUM_PARENT_DICT = {
|
||||
# "Pumpkin Farm": None,
|
||||
# "AlbumInFolder": "SubFolder2",
|
||||
# "Test Album": None,
|
||||
# }
|
||||
|
||||
# ALBUM_FOLDER_NAMES_DICT = {
|
||||
# "Pumpkin Farm": [],
|
||||
# "AlbumInFolder": ["Folder1", "SubFolder2"],
|
||||
# "Test Album": [],
|
||||
# }
|
||||
|
||||
ALBUM_LEN_DICT = {
|
||||
"Pumpkin Farm": 3,
|
||||
"Test Album": 1,
|
||||
"Test Album (1)": 1,
|
||||
# "AlbumInFolder": 2,
|
||||
}
|
||||
|
||||
ALBUM_PHOTO_UUID_DICT = {
|
||||
"Pumpkin Farm": ["HrK3ZQdlQ7qpDA0FgOYXLA","15uNd7%8RguTEgNPKHfTWw","8SOE9s0XQVGsuq4ONohTng"],
|
||||
"Test Album": ["8SOE9s0XQVGsuq4ONohTng"],
|
||||
"Test Album (1)": ["15uNd7%8RguTEgNPKHfTWw"],
|
||||
# "AlbumInFolder": [
|
||||
# "3DD2C897-F19E-4CA6-8C22-B027D5A71907",
|
||||
# "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51",
|
||||
# ],
|
||||
}
|
||||
|
||||
######### Test FolderInfo ##########
|
||||
|
||||
|
||||
def test_folders_1(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
folders = photosdb.folders
|
||||
assert folders == []
|
||||
assert "Folders not yet implemented for this DB version" in caplog.text
|
||||
|
||||
# # top level folders
|
||||
# folders = photosdb.folders
|
||||
# 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(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# check folder names
|
||||
folder_names = photosdb.folder_names
|
||||
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
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
assert len(folders[0]) == len(TOP_LEVEL_CHILDREN)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Folders not yet impleted in Photos < 5")
|
||||
def test_folders_children():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
# children of top level folder
|
||||
children = folders[0].folders
|
||||
children_names = [f.title for f in children]
|
||||
assert sorted(children_names) == sorted(TOP_LEVEL_CHILDREN)
|
||||
|
||||
for child in folders[0].folders:
|
||||
# check valid children FolderInfo
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folders[0].uuid
|
||||
|
||||
# check folder names
|
||||
folder_names = [f.title for f in folders]
|
||||
assert sorted(folder_names) == sorted(TOP_LEVEL_FOLDERS)
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Folders not yet impleted in Photos < 5")
|
||||
def test_folders_parent():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
# parent of top level folder should be none
|
||||
for folder in folders:
|
||||
assert folder.parent is None
|
||||
for child in folder.folders:
|
||||
# children's parent uuid should match folder uuid
|
||||
assert child.parent
|
||||
assert child.parent.uuid == folder.uuid
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Folders not yet impleted in Photos < 5")
|
||||
def test_folders_albums():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
# top level folders
|
||||
folders = photosdb.folders
|
||||
|
||||
for folder in folders:
|
||||
name = folder.title
|
||||
albums = [a.title for a in folder.albums]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
for child in folder.folders:
|
||||
name = child.title
|
||||
albums = [a.title for a in child.albums]
|
||||
assert sorted(albums) == sorted(FOLDER_ALBUM_DICT[name])
|
||||
|
||||
|
||||
########## Test AlbumInfo ##########
|
||||
|
||||
|
||||
def test_albums_1():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
assert len(albums) == 3
|
||||
|
||||
# check names
|
||||
album_names = [a.title for a in albums]
|
||||
assert sorted(album_names) == sorted(ALBUM_NAMES)
|
||||
|
||||
|
||||
def test_albums_parent(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
parent = album.parent.title if album.parent else None
|
||||
assert "Folders not yet implemented for this DB version" in caplog.text
|
||||
# assert parent == ALBUM_PARENT_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_folder_names(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
folder_names = album.folder_names
|
||||
assert "Folders not yet implemented for this DB version" in caplog.text
|
||||
# assert folder_names == ALBUM_FOLDER_NAMES_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_folders(caplog):
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
folders = album.folder_list
|
||||
assert "Folders not yet implemented for this DB version" in caplog.text
|
||||
# folder_names = [f.title for f in folders]
|
||||
# assert folder_names == ALBUM_FOLDER_NAMES_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_len():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
assert len(album) == ALBUM_LEN_DICT[album.title]
|
||||
|
||||
|
||||
def test_albums_photos():
|
||||
import osxphotos
|
||||
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
|
||||
albums = photosdb.albums
|
||||
|
||||
for album in albums:
|
||||
photos = album.photos
|
||||
assert len(photos) == ALBUM_LEN_DICT[album.title]
|
||||
assert len(photos) == len(album)
|
||||
for photo in photos:
|
||||
assert photo.uuid in ALBUM_PHOTO_UUID_DICT[album.title]
|
||||
@@ -24,6 +24,7 @@ PERSONS = ["Katie", "Suzy", "Maria", _UNKNOWN_PERSON]
|
||||
ALBUMS = [
|
||||
"Pumpkin Farm",
|
||||
"Test Album",
|
||||
"AlbumInFolder",
|
||||
] # Note: there are 2 albums named "Test Album" for testing duplicate album names
|
||||
KEYWORDS_DICT = {
|
||||
"Kids": 4,
|
||||
@@ -40,6 +41,7 @@ PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1, _UNKNOWN_PERSON: 1}
|
||||
ALBUM_DICT = {
|
||||
"Pumpkin Farm": 3,
|
||||
"Test Album": 2,
|
||||
"AlbumInFolder": 2,
|
||||
} # Note: there are 2 albums named "Test Album" for testing duplicate album names
|
||||
|
||||
UUID_DICT = {
|
||||
|
||||
Reference in New Issue
Block a user