diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 0a0fc1f2..90aaf9a3 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.42.73" +__version__ = "0.42.74" diff --git a/osxphotos/phototemplate.py b/osxphotos/phototemplate.py index 32f4f3b1..f7d2491c 100644 --- a/osxphotos/phototemplate.py +++ b/osxphotos/phototemplate.py @@ -574,7 +574,7 @@ class PhotoTemplate: if self.expand_inplace or delim is not None: 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: vals = self.get_template_value_filter(filter_, vals) diff --git a/tests/test_cli.py b/tests/test_cli.py index fe065453..b1497801 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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): """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']}" 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 + diff --git a/tests/test_template.py b/tests/test_template.py index ded3c02c..b9cf66b7 100644 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -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") def photosdb_places(): @@ -1179,3 +1185,11 @@ def test_detected_text(photosdb): for template, value in TEMPLATE_VALUES_DETECTED_TEXT.items(): rendered, _ = photo.render_template(template) 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)