Added expand_inplace to PhotoTemplate.render

This commit is contained in:
Rhet Turnbull
2020-06-28 13:46:35 -07:00
parent 3693d65b82
commit ff0328785f
5 changed files with 118 additions and 14 deletions

View File

@@ -168,8 +168,8 @@ def test_missing():
photos = photosdb.photos(uuid=["od0fmC7NQx+ayVr+%i06XA"])
assert len(photos) == 1
p = photos[0]
assert p.path == None
assert p.ismissing == True
assert p.path is None
assert p.ismissing
def test_favorite():

View File

@@ -458,3 +458,48 @@ def test_subst_strftime():
rendered, unmatched = photo.render_template("{created.strftime}")
assert rendered[0] == "_"
def test_subst_expand_inplace_1():
""" Test that substitutions are correct when expand_inplace=True """
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_15_1)
# one album, one keyword, two persons
photo = photosdb.photos(uuid=[UUID_DICT["1_1_2"]])[0]
template = "{person}"
expected = ["Katie,Suzy"]
rendered, unknown = photo.render_template(template, expand_inplace=True)
assert sorted(rendered) == sorted(expected)
def test_subst_expand_inplace_2():
""" Test that substitutions are correct when expand_inplace=True """
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_15_1)
# one album, one keyword, two persons
photo = photosdb.photos(uuid=[UUID_DICT["1_1_2"]])[0]
template = "{person}-{keyword}"
expected = ["Katie,Suzy-Kids"]
rendered, unknown = photo.render_template(template, expand_inplace=True)
assert sorted(rendered) == sorted(expected)
def test_subst_expand_inplace_3():
""" Test that substitutions are correct when expand_inplace=True and inplace_sep specified"""
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_15_1)
# one album, one keyword, two persons
photo = photosdb.photos(uuid=[UUID_DICT["1_1_2"]])[0]
template = "{person}-{keyword}"
expected = ["Katie; Suzy-Kids"]
rendered, unknown = photo.render_template(
template, expand_inplace=True, inplace_sep="; "
)
assert sorted(rendered) == sorted(expected)