Fix for #506
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
""" version info """
|
""" version info """
|
||||||
|
|
||||||
__version__ = "0.42.73"
|
__version__ = "0.42.74"
|
||||||
|
|||||||
@@ -574,7 +574,7 @@ class PhotoTemplate:
|
|||||||
|
|
||||||
if self.expand_inplace or delim is not None:
|
if self.expand_inplace or delim is not None:
|
||||||
sep = delim if delim is not None else self.inplace_sep
|
sep = delim if delim is not None else self.inplace_sep
|
||||||
vals = [sep.join(sorted(vals))]
|
vals = [sep.join(sorted(vals))] if vals else []
|
||||||
|
|
||||||
for filter_ in filters:
|
for filter_ in filters:
|
||||||
vals = self.get_template_value_filter(filter_, vals)
|
vals = self.get_template_value_filter(filter_, vals)
|
||||||
|
|||||||
@@ -793,6 +793,10 @@ UUID_DICT_FOLDER_ALBUM_SEQ = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID_EMPTY_TITLE = "7783E8E6-9CAC-40F3-BE22-81FB7051C266" # IMG_3092.heic
|
||||||
|
FILENAME_EMPTY_TITLE = "IMG_3092.heic"
|
||||||
|
DESCRIPTION_TEMPLATE_EMPTY_TITLE = "{title,No Title} and {descr,No Descr}"
|
||||||
|
DESCRIPTION_VALUE_EMPTY_TITLE = "No Title and No Descr"
|
||||||
|
|
||||||
def modify_file(filename):
|
def modify_file(filename):
|
||||||
"""appends data to a file to modify it"""
|
"""appends data to a file to modify it"""
|
||||||
@@ -7121,3 +7125,39 @@ def test_export_album_seq():
|
|||||||
f"{UUID_DICT_FOLDER_ALBUM_SEQ[uuid]['album']}/{UUID_DICT_FOLDER_ALBUM_SEQ[uuid]['result']}"
|
f"{UUID_DICT_FOLDER_ALBUM_SEQ[uuid]['album']}/{UUID_DICT_FOLDER_ALBUM_SEQ[uuid]['result']}"
|
||||||
in files
|
in files
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.skipif(exiftool is None, reason="exiftool not installed")
|
||||||
|
def test_export_description_template():
|
||||||
|
"""Test for issue #506"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
from osxphotos.cli import cli
|
||||||
|
from osxphotos.exiftool import ExifTool
|
||||||
|
|
||||||
|
runner = CliRunner()
|
||||||
|
cwd = os.getcwd()
|
||||||
|
# pylint: disable=not-context-manager
|
||||||
|
with runner.isolated_filesystem():
|
||||||
|
result = runner.invoke(
|
||||||
|
cli,
|
||||||
|
[
|
||||||
|
"export",
|
||||||
|
"--db",
|
||||||
|
os.path.join(cwd, PHOTOS_DB_15_7),
|
||||||
|
".",
|
||||||
|
"--sidecar=json",
|
||||||
|
f"--uuid={UUID_EMPTY_TITLE}",
|
||||||
|
"-V",
|
||||||
|
"--description-template",
|
||||||
|
DESCRIPTION_TEMPLATE_EMPTY_TITLE,
|
||||||
|
"--exiftool"
|
||||||
|
],
|
||||||
|
)
|
||||||
|
assert result.exit_code == 0
|
||||||
|
exif = ExifTool(FILENAME_EMPTY_TITLE).asdict()
|
||||||
|
assert exif["EXIF:ImageDescription"] == DESCRIPTION_VALUE_EMPTY_TITLE
|
||||||
|
|
||||||
|
|||||||
@@ -393,6 +393,12 @@ UUID_ALBUM_SEQ = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID_EMPTY_TITLE = "7783E8E6-9CAC-40F3-BE22-81FB7051C266" # IMG_3092.heic
|
||||||
|
|
||||||
|
TEMPLATE_VALUES_EMPTY_TITLE = {
|
||||||
|
"{title,No Title} and {descr,No Descr}": "No Title and No Descr"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def photosdb_places():
|
def photosdb_places():
|
||||||
@@ -1179,3 +1185,11 @@ def test_detected_text(photosdb):
|
|||||||
for template, value in TEMPLATE_VALUES_DETECTED_TEXT.items():
|
for template, value in TEMPLATE_VALUES_DETECTED_TEXT.items():
|
||||||
rendered, _ = photo.render_template(template)
|
rendered, _ = photo.render_template(template)
|
||||||
assert value in "".join(rendered)
|
assert value in "".join(rendered)
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_title(photosdb):
|
||||||
|
"""Test for issue #506"""
|
||||||
|
photo = photosdb.get_photo(UUID_EMPTY_TITLE)
|
||||||
|
for template, value in TEMPLATE_VALUES_EMPTY_TITLE.items():
|
||||||
|
rendered, _ = photo.render_template(template)
|
||||||
|
assert value in "".join(rendered)
|
||||||
|
|||||||
Reference in New Issue
Block a user