Feature phototables (#1059)

* Added tables() method to PhotoInfo to get access to underlying tables

* This time with the phototables code...
This commit is contained in:
Rhet Turnbull
2023-04-16 09:02:59 -07:00
committed by GitHub
parent 1b0c91db97
commit ed543aa2d0
6 changed files with 271 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ from collections import namedtuple
import pytest
import osxphotos
from osxphotos._constants import _UNKNOWN_PERSON
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
@@ -531,9 +532,10 @@ def test_photosdb_repr():
def test_photosinfo_repr():
import osxphotos
import datetime # needed for eval to work
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
photos = photosdb.photos(uuid=[UUID_DICT["favorite"]])
photo = photos[0]
@@ -689,3 +691,10 @@ def test_fingerprint(photosdb):
for uuid, fingerprint in UUID_FINGERPRINT.items():
photo = photosdb.get_photo(uuid)
assert photo.fingerprint == fingerprint
def test_tables(photosdb: osxphotos.PhotosDB):
"""Test PhotoInfo.tables"""
photo = photosdb.get_photo(UUID_DICT["favorite"])
tables = photo.tables()
assert tables is None

View File

@@ -1304,3 +1304,14 @@ def test_photosdb_photos_by_uuid(photosdb: osxphotos.PhotosDB):
assert len(photos) == len(UUID_DICT)
for photo in photos:
assert photo.uuid in UUID_DICT.values()
def test_tables(photosdb: osxphotos.PhotosDB):
"""Test PhotoInfo.tables"""
photo = photosdb.get_photo(UUID_DICT["in_album"])
tables = photo.tables()
assert isinstance(tables, osxphotos.PhotoTables)
assert tables.ZASSET.ZUUID[0] == photo.uuid
assert tables.ZADDITIONALASSETATTRIBUTES.ZTITLE[0] == photo.title
assert len(tables.ZASSET.rows()) == 1
assert tables.ZASSET.rows_dict()[0]["ZUUID"] == photo.uuid