diff --git a/osxphotos/__init__.py b/osxphotos/__init__.py index a239b41a..f7b8379c 100644 --- a/osxphotos/__init__.py +++ b/osxphotos/__init__.py @@ -387,10 +387,7 @@ class PhotosDB: c.execute( "SELECT value from LiGlobals where LiGlobals.keyPath is 'libraryVersion'" ) - for ver in c: - version = ver[0] - break # TODO: is there a more pythonic way to do get the first element from cursor? - + version = c.fetchone()[0] conn.close() if version not in _TESTED_DB_VERSIONS: diff --git a/tests/test_10_12_6.py b/tests/test_10_12_6.py index b25b758b..999c7be5 100644 --- a/tests/test_10_12_6.py +++ b/tests/test_10_12_6.py @@ -43,7 +43,8 @@ def test_db_version(): import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) - assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + # assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + assert photosdb.get_db_version() == "2622" def test_os_version(): @@ -170,36 +171,3 @@ def test_keyword_not_in_album(): assert len(photos3) == 1 assert photos3[0].uuid() == "Pj99JmYjQkeezdY2OFuSaw" - -# def main(): -# photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) -# print(photosdb.keywords()) -# print(photosdb.persons()) -# print(photosdb.albums()) - -# print(photosdb.keywords_as_dict()) -# print(photosdb.persons_as_dict()) -# print(photosdb.albums_as_dict()) - -# # # find all photos with Keyword = Foo and containing John Smith -# # photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"]) -# # -# # # find all photos that include Alice Smith but do not contain the keyword Bar -# # photos = [p for p in photosdb.photos(persons=["Alice Smith"]) -# # if p not in photosdb.photos(keywords=["Bar"]) ] -# photos = photosdb.photos() -# for p in photos: -# print( -# p.uuid(), -# p.filename(), -# p.date(), -# p.description(), -# p.name(), -# p.keywords(), -# p.albums(), -# p.persons(), -# p.path(), -# ) - -# if __name__ == "__main__": -# main() diff --git a/tests/test_catalina_10_15_1.py b/tests/test_catalina_10_15_1.py index a6172e9d..7db2a170 100644 --- a/tests/test_catalina_10_15_1.py +++ b/tests/test_catalina_10_15_1.py @@ -43,7 +43,8 @@ def test_db_version(): import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) - assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + # assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + assert photosdb.get_db_version() == "6000" def test_os_version(): diff --git a/tests/test_highsierra.py b/tests/test_highsierra.py index 6cd8bb72..6805a53d 100644 --- a/tests/test_highsierra.py +++ b/tests/test_highsierra.py @@ -42,7 +42,8 @@ def test_db_version(): import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) - assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + assert photosdb.get_db_version() == "3301" + # assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS def test_os_version(): @@ -169,36 +170,3 @@ def test_keyword_not_in_album(): assert len(photos3) == 1 assert photos3[0].uuid() == "6iAZJP7ZQ5iXxapoJb3ytA" - -# def main(): -# photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) -# print(photosdb.keywords()) -# print(photosdb.persons()) -# print(photosdb.albums()) - -# print(photosdb.keywords_as_dict()) -# print(photosdb.persons_as_dict()) -# print(photosdb.albums_as_dict()) - -# # # find all photos with Keyword = Foo and containing John Smith -# # photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"]) -# # -# # # find all photos that include Alice Smith but do not contain the keyword Bar -# # photos = [p for p in photosdb.photos(persons=["Alice Smith"]) -# # if p not in photosdb.photos(keywords=["Bar"]) ] -# photos = photosdb.photos() -# for p in photos: -# print( -# p.uuid(), -# p.filename(), -# p.date(), -# p.description(), -# p.name(), -# p.keywords(), -# p.albums(), -# p.persons(), -# p.path(), -# ) - -# if __name__ == "__main__": -# main() diff --git a/tests/test_mojave_10_14_5.py b/tests/test_mojave_10_14_5.py index 740b86c8..80806ded 100644 --- a/tests/test_mojave_10_14_5.py +++ b/tests/test_mojave_10_14_5.py @@ -42,7 +42,8 @@ def test_db_version(): import osxphotos photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) - assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + # assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + assert photosdb.get_db_version() == "4016" def test_os_version(): @@ -169,36 +170,3 @@ def test_keyword_not_in_album(): assert len(photos3) == 1 assert photos3[0].uuid() == "od0fmC7NQx+ayVr+%i06XA" - -# def main(): -# photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) -# print(photosdb.keywords()) -# print(photosdb.persons()) -# print(photosdb.albums()) - -# print(photosdb.keywords_as_dict()) -# print(photosdb.persons_as_dict()) -# print(photosdb.albums_as_dict()) - -# # # find all photos with Keyword = Foo and containing John Smith -# # photos = photosdb.photos(keywords=["Foo"],persons=["John Smith"]) -# # -# # # find all photos that include Alice Smith but do not contain the keyword Bar -# # photos = [p for p in photosdb.photos(persons=["Alice Smith"]) -# # if p not in photosdb.photos(keywords=["Bar"]) ] -# photos = photosdb.photos() -# for p in photos: -# print( -# p.uuid(), -# p.filename(), -# p.date(), -# p.description(), -# p.name(), -# p.keywords(), -# p.albums(), -# p.persons(), -# p.path(), -# ) - -# if __name__ == "__main__": -# main() diff --git a/tests/test_mojave_10_14_6.py b/tests/test_mojave_10_14_6.py index ad96fa81..ea8ad2e2 100644 --- a/tests/test_mojave_10_14_6.py +++ b/tests/test_mojave_10_14_6.py @@ -43,6 +43,7 @@ def test_db_version(): photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB) assert photosdb.get_db_version() in osxphotos._TESTED_DB_VERSIONS + assert photosdb.get_db_version() == "4025" def test_os_version():