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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user