Added {album}, {keyword}, and {person} to template system

This commit is contained in:
Rhet Turnbull
2020-04-04 13:58:54 -07:00
parent 6a898886dd
commit 507c4a3740
7 changed files with 245 additions and 85 deletions

View File

@@ -190,6 +190,22 @@ def test_subst_multi_2_1_1():
assert sorted(rendered) == sorted(expected)
def test_subst_multi_2_1_1_single():
""" Test that substitutions are correct """
# 2 albums, 1 keyword, 1 person but only do keywords
import osxphotos
from osxphotos.template import render_filepath_template
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_2)
# one album, one keyword, two persons
photo = photosdb.photos(uuid=[UUID_DICT["2_1_1"]])[0]
template = "{keyword}"
expected = ["Kids"]
rendered, _ = render_filepath_template(template, photo)
assert sorted(rendered) == sorted(expected)
def test_subst_multi_0_2_0():
""" Test that substitutions are correct """
# 0 albums, 2 keywords, 0 persons
@@ -206,6 +222,22 @@ def test_subst_multi_0_2_0():
assert sorted(rendered) == sorted(expected)
def test_subst_multi_0_2_0_single():
""" Test that substitutions are correct """
# 0 albums, 2 keywords, 0 persons, but only do albums
import osxphotos
from osxphotos.template import render_filepath_template
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB_2)
# one album, one keyword, two persons
photo = photosdb.photos(uuid=[UUID_DICT["0_2_0"]])[0]
template = "{created.year}/{album}"
expected = ["2019/_"]
rendered, _ = render_filepath_template(template, photo)
assert sorted(rendered) == sorted(expected)
def test_subst_multi_0_2_0_default_val():
""" Test that substitutions are correct """
# 0 albums, 2 keywords, 0 persons, default vals provided