diff --git a/osxphotos/_version.py b/osxphotos/_version.py
index 639f6176..a7ef9074 100644
--- a/osxphotos/_version.py
+++ b/osxphotos/_version.py
@@ -1,3 +1,3 @@
""" version info """
-__version__ = "0.29.11"
+__version__ = "0.29.12"
diff --git a/osxphotos/photosdb/photosdb.py b/osxphotos/photosdb/photosdb.py
index 2079fb7f..22208e02 100644
--- a/osxphotos/photosdb/photosdb.py
+++ b/osxphotos/photosdb/photosdb.py
@@ -2133,7 +2133,11 @@ class PhotosDB:
if album in self._dbalbum_titles:
title_set = set()
for album_id in self._dbalbum_titles[album]:
- title_set.update(self._dbalbums_album[album_id])
+ try:
+ title_set.update(self._dbalbums_album[album_id])
+ except KeyError:
+ # an empty album will be in _dbalbum_titles but not _dbalbums_album
+ pass
album_set.update(title_set)
else:
logging.debug(f"Could not find album '{album}' in database")
diff --git a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-shm b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-shm
index 7c919e57..3b514a95 100644
Binary files a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-shm and b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-shm differ
diff --git a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-wal b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-wal
index 0a0274a5..db3b7d87 100644
Binary files a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-wal and b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite-wal differ
diff --git a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite.lock b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite.lock
index 2f5f3463..d96edccc 100644
--- a/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite.lock
+++ b/tests/Test-10.15.5.photoslibrary/database/Photos.sqlite.lock
@@ -7,7 +7,7 @@
hostuuid
9575E48B-8D5F-5654-ABAC-4431B1167324
pid
- 452
+ 703
processname
photolibraryd
uid
diff --git a/tests/Test-10.15.5.photoslibrary/database/search/psi.sqlite b/tests/Test-10.15.5.photoslibrary/database/search/psi.sqlite
index 091b63fb..1ac29277 100644
Binary files a/tests/Test-10.15.5.photoslibrary/database/search/psi.sqlite and b/tests/Test-10.15.5.photoslibrary/database/search/psi.sqlite differ
diff --git a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm
index c9b73dea..7c42481d 100644
Binary files a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm and b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-shm differ
diff --git a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal
index ac1e064c..f841cc00 100644
Binary files a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal and b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/CLSBusinessCategoryCache.POI.sqlite-wal differ
diff --git a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist
index 22a2691a..842aacf2 100644
Binary files a/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist and b/tests/Test-10.15.5.photoslibrary/private/com.apple.photoanalysisd/caches/graph/changetoken.plist differ
diff --git a/tests/Test-10.15.5.photoslibrary/resources/journals/Album-change.plj b/tests/Test-10.15.5.photoslibrary/resources/journals/Album-change.plj
index 748b1680..87e13f53 100644
Binary files a/tests/Test-10.15.5.photoslibrary/resources/journals/Album-change.plj and b/tests/Test-10.15.5.photoslibrary/resources/journals/Album-change.plj differ
diff --git a/tests/Test-10.15.5.photoslibrary/resources/journals/Folder-change.plj b/tests/Test-10.15.5.photoslibrary/resources/journals/Folder-change.plj
new file mode 100644
index 00000000..bdec336d
Binary files /dev/null and b/tests/Test-10.15.5.photoslibrary/resources/journals/Folder-change.plj differ
diff --git a/tests/Test-10.15.5.photoslibrary/resources/journals/HistoryToken.plist b/tests/Test-10.15.5.photoslibrary/resources/journals/HistoryToken.plist
index 2621d7f7..9b4deea4 100644
Binary files a/tests/Test-10.15.5.photoslibrary/resources/journals/HistoryToken.plist and b/tests/Test-10.15.5.photoslibrary/resources/journals/HistoryToken.plist differ
diff --git a/tests/test_catalina_10_15_5.py b/tests/test_catalina_10_15_5.py
index 2831952d..8504f1f5 100644
--- a/tests/test_catalina_10_15_5.py
+++ b/tests/test_catalina_10_15_5.py
@@ -24,10 +24,11 @@ KEYWORDS = [
PERSONS = ["Katie", "Suzy", "Maria", _UNKNOWN_PERSON]
ALBUMS = [
"Pumpkin Farm",
- "Test Album",
+ "Test Album", # there are 2 albums named "Test Album" for testing duplicate album names
"AlbumInFolder",
"Raw",
-] # Note: there are 2 albums named "Test Album" for testing duplicate album names
+ "I have a deleted twin", # there's an empty album with same name that has been deleted
+]
KEYWORDS_DICT = {
"Kids": 4,
"wedding": 2,
@@ -45,6 +46,7 @@ ALBUM_DICT = {
"Test Album": 2,
"AlbumInFolder": 2,
"Raw": 4,
+ "I have a deleted twin": 1,
} # Note: there are 2 albums named "Test Album" for testing duplicate album names
UUID_DICT = {
@@ -232,7 +234,7 @@ def test_missing():
photos = photosdb.photos(uuid=[UUID_DICT["missing"]])
assert len(photos) == 1
p = photos[0]
- assert p.path == None
+ assert p.path is None
assert p.ismissing == True
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 384137e9..cda217e0 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -49,6 +49,10 @@ CLI_EXPORT_FILENAMES = [
"wedding_edited.jpeg",
]
+CLI_EXPORT_FILENAMES_ALBUM = ["Pumkins1.jpg", "Pumkins2.jpg", "Pumpkins3.jpg"]
+
+CLI_EXPORT_FILENAMES_DELETED_TWIN = ["wedding.jpg", "wedding_edited.jpeg"]
+
CLI_EXPORT_EDITED_SUFFIX = "_bearbeiten"
CLI_EXPORT_FILENAMES_EDITED_SUFFIX = [
@@ -165,6 +169,8 @@ CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES2 = [
"Test Album-Pumkins1.jpg",
"Test Album-Pumkins2.jpg",
"None-IMG_1693.tif",
+ "I have a deleted twin-wedding.jpg",
+ "I have a deleted twin-wedding_edited.jpeg",
]
CLI_EXPORT_UUID = "D79B8D77-BFFC-460B-9312-034F2877D35B"
@@ -947,6 +953,54 @@ def test_export_filename_template_3():
assert "Error: Invalid template" in result.output
+def test_export_album():
+ """Test export of an album """
+ import glob
+ import os
+ import os.path
+ import osxphotos
+ from osxphotos.__main__ import export
+
+ runner = CliRunner()
+ cwd = os.getcwd()
+ # pylint: disable=not-context-manager
+ with runner.isolated_filesystem():
+ result = runner.invoke(
+ export,
+ [os.path.join(cwd, PHOTOS_DB_15_5), ".", "--album", "Pumpkin Farm", "-V"],
+ )
+ assert result.exit_code == 0
+ files = glob.glob("*")
+ assert sorted(files) == sorted(CLI_EXPORT_FILENAMES_ALBUM)
+
+
+def test_export_album_deleted_twin():
+ """Test export of an album where album of same name has been deleted """
+ import glob
+ import os
+ import os.path
+ import osxphotos
+ from osxphotos.__main__ import export
+
+ runner = CliRunner()
+ cwd = os.getcwd()
+ # pylint: disable=not-context-manager
+ with runner.isolated_filesystem():
+ result = runner.invoke(
+ export,
+ [
+ os.path.join(cwd, PHOTOS_DB_15_5),
+ ".",
+ "--album",
+ "I have a deleted twin",
+ "-V",
+ ],
+ )
+ assert result.exit_code == 0
+ files = glob.glob("*")
+ assert sorted(files) == sorted(CLI_EXPORT_FILENAMES_DELETED_TWIN)
+
+
def test_places():
import json
import os