added __len__ to PhotosDB, closes #44

This commit is contained in:
Rhet Turnbull 2020-04-18 23:57:34 -07:00
parent 87eb84fddd
commit 1867c1d747
3 changed files with 18 additions and 0 deletions

View File

@ -2156,3 +2156,7 @@ class PhotosDB:
return self.__dict__ == other.__dict__
return False
def __len__(self):
""" returns number of photos in the database """
return len(self._dbphotos)

View File

@ -118,6 +118,13 @@ def test_init5():
with pytest.raises(Exception):
assert osxphotos.PhotosDB()
def test_db_len():
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
assert len(photosdb) == 8
def test_db_version():
import osxphotos

View File

@ -58,6 +58,13 @@ def test_db_version():
assert photosdb.db_version in osxphotos._constants._TESTED_DB_VERSIONS
assert photosdb.db_version == "4025"
def test_db_len():
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
assert len(photosdb) == 7
def test_os_version():
import osxphotos