added __len__ to PhotosDB, closes #44
This commit is contained in:
@@ -2156,3 +2156,7 @@ class PhotosDB:
|
|||||||
return self.__dict__ == other.__dict__
|
return self.__dict__ == other.__dict__
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
""" returns number of photos in the database """
|
||||||
|
return len(self._dbphotos)
|
||||||
|
|||||||
@@ -118,6 +118,13 @@ def test_init5():
|
|||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception):
|
||||||
assert osxphotos.PhotosDB()
|
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():
|
def test_db_version():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ def test_db_version():
|
|||||||
assert photosdb.db_version in osxphotos._constants._TESTED_DB_VERSIONS
|
assert photosdb.db_version in osxphotos._constants._TESTED_DB_VERSIONS
|
||||||
assert photosdb.db_version == "4025"
|
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():
|
def test_os_version():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|||||||
Reference in New Issue
Block a user