Fix for bug in handling of deleted albums to address issue #156
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.29.11"
|
__version__ = "0.29.12"
|
||||||
|
|||||||
@@ -2133,7 +2133,11 @@ class PhotosDB:
|
|||||||
if album in self._dbalbum_titles:
|
if album in self._dbalbum_titles:
|
||||||
title_set = set()
|
title_set = set()
|
||||||
for album_id in self._dbalbum_titles[album]:
|
for album_id in self._dbalbum_titles[album]:
|
||||||
|
try:
|
||||||
title_set.update(self._dbalbums_album[album_id])
|
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)
|
album_set.update(title_set)
|
||||||
else:
|
else:
|
||||||
logging.debug(f"Could not find album '{album}' in database")
|
logging.debug(f"Could not find album '{album}' in database")
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,7 @@
|
|||||||
<key>hostuuid</key>
|
<key>hostuuid</key>
|
||||||
<string>9575E48B-8D5F-5654-ABAC-4431B1167324</string>
|
<string>9575E48B-8D5F-5654-ABAC-4431B1167324</string>
|
||||||
<key>pid</key>
|
<key>pid</key>
|
||||||
<integer>452</integer>
|
<integer>703</integer>
|
||||||
<key>processname</key>
|
<key>processname</key>
|
||||||
<string>photolibraryd</string>
|
<string>photolibraryd</string>
|
||||||
<key>uid</key>
|
<key>uid</key>
|
||||||
|
|||||||
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.
@@ -24,10 +24,11 @@ KEYWORDS = [
|
|||||||
PERSONS = ["Katie", "Suzy", "Maria", _UNKNOWN_PERSON]
|
PERSONS = ["Katie", "Suzy", "Maria", _UNKNOWN_PERSON]
|
||||||
ALBUMS = [
|
ALBUMS = [
|
||||||
"Pumpkin Farm",
|
"Pumpkin Farm",
|
||||||
"Test Album",
|
"Test Album", # there are 2 albums named "Test Album" for testing duplicate album names
|
||||||
"AlbumInFolder",
|
"AlbumInFolder",
|
||||||
"Raw",
|
"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 = {
|
KEYWORDS_DICT = {
|
||||||
"Kids": 4,
|
"Kids": 4,
|
||||||
"wedding": 2,
|
"wedding": 2,
|
||||||
@@ -45,6 +46,7 @@ ALBUM_DICT = {
|
|||||||
"Test Album": 2,
|
"Test Album": 2,
|
||||||
"AlbumInFolder": 2,
|
"AlbumInFolder": 2,
|
||||||
"Raw": 4,
|
"Raw": 4,
|
||||||
|
"I have a deleted twin": 1,
|
||||||
} # Note: there are 2 albums named "Test Album" for testing duplicate album names
|
} # Note: there are 2 albums named "Test Album" for testing duplicate album names
|
||||||
|
|
||||||
UUID_DICT = {
|
UUID_DICT = {
|
||||||
@@ -232,7 +234,7 @@ def test_missing():
|
|||||||
photos = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
assert p.path == None
|
assert p.path is None
|
||||||
assert p.ismissing == True
|
assert p.ismissing == True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ CLI_EXPORT_FILENAMES = [
|
|||||||
"wedding_edited.jpeg",
|
"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_EDITED_SUFFIX = "_bearbeiten"
|
||||||
|
|
||||||
CLI_EXPORT_FILENAMES_EDITED_SUFFIX = [
|
CLI_EXPORT_FILENAMES_EDITED_SUFFIX = [
|
||||||
@@ -165,6 +169,8 @@ CLI_EXPORTED_FILENAME_TEMPLATE_FILENAMES2 = [
|
|||||||
"Test Album-Pumkins1.jpg",
|
"Test Album-Pumkins1.jpg",
|
||||||
"Test Album-Pumkins2.jpg",
|
"Test Album-Pumkins2.jpg",
|
||||||
"None-IMG_1693.tif",
|
"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"
|
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
|
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():
|
def test_places():
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|||||||
Reference in New Issue
Block a user