Added error logging to {detected_text} processing, #499

This commit is contained in:
Rhet Turnbull
2021-07-29 06:23:02 -07:00
parent de715d2afd
commit b1c0fb3e82
5 changed files with 54 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
""" Test template.py """
import json
import os
import re
@@ -7,6 +8,7 @@ from photoinfo_mock import PhotoInfoMock
import osxphotos
from osxphotos.exiftool import get_exiftool_path
from osxphotos.export_db import ExportDBInMemory
from osxphotos.phototemplate import (
TEMPLATE_SUBSTITUTIONS,
TEMPLATE_SUBSTITUTIONS_MULTI_VALUED,
@@ -1177,3 +1179,13 @@ 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_detected_text_caching(photosdb):
"""Test {detected_text} template caches values"""
exportdb = ExportDBInMemory(None)
exportdb.set_detected_text_for_uuid(UUID_DETECTED_TEXT, json.dumps([["foo", 0.9]]))
photo = photosdb.get_photo(UUID_DETECTED_TEXT)
options = RenderOptions(exportdb=exportdb)
rendered, _ = photo.render_template("{detected_text}", options=options)
assert rendered[0] == "foo"