More PhotoInfo.albums refactoring, closes #169

This commit is contained in:
Rhet Turnbull
2020-06-21 08:18:11 -07:00
parent 32806c8459
commit 538bac7ade
8 changed files with 52 additions and 31 deletions

View File

@@ -124,7 +124,7 @@ def test_attributes():
)
assert p.description == "Girl holding pumpkin"
assert p.title == "I found one!"
assert p.albums == ["Pumpkin Farm", "AlbumInFolder"]
assert sorted(p.albums) == ["AlbumInFolder", "Pumpkin Farm"]
assert p.persons == ["Katie"]
assert p.path.endswith(
"/tests/Test-10.12.6.photoslibrary/Masters/2019/08/24/20190824-030824/Pumkins2.jpg"

View File

@@ -106,6 +106,7 @@ def test_init4():
except:
pass
def test_init5(mocker):
# test failed get_last_library_path
import osxphotos
@@ -116,7 +117,6 @@ def test_init5(mocker):
# get_last_library actually in utils but need to patch it in photosdb because it's imported into photosdb
# because of the layout of photosdb/ need to patch it this way...don't really understand why, but it works
mocker.patch("osxphotos.photosdb.photosdb.get_last_library_path", new=bad_library)
with pytest.raises(Exception):
assert osxphotos.PhotosDB()
@@ -207,7 +207,7 @@ def test_attributes():
)
assert p.description == "Girl holding pumpkin"
assert p.title == "I found one!"
assert p.albums == ["Pumpkin Farm", "Test Album", "Multi Keyword"]
assert sorted(p.albums) == ["Multi Keyword", "Pumpkin Farm", "Test Album"]
assert p.persons == ["Katie"]
assert p.path.endswith(
"tests/Test-10.15.1.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg"

View File

@@ -215,7 +215,7 @@ def test_attributes():
)
assert p.description == "Girl holding pumpkin"
assert p.title == "I found one!"
assert p.albums == ["Pumpkin Farm", "Test Album"]
assert sorted(p.albums) == ["Pumpkin Farm", "Test Album"]
assert p.persons == ["Katie"]
assert p.path.endswith(
"tests/Test-10.15.4.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg"

View File

@@ -228,7 +228,7 @@ def test_attributes():
)
assert p.description == "Girl holding pumpkin"
assert p.title == "I found one!"
assert p.albums == ["Pumpkin Farm", "Test Album"]
assert sorted(p.albums) == ["Pumpkin Farm", "Test Album"]
assert p.persons == ["Katie"]
assert p.path.endswith(
"tests/Test-10.15.5.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg"

View File

@@ -355,7 +355,10 @@ def test_query_uuid():
for key_ in json_expected:
assert key_ in json_got
if key_ != "path":
assert json_expected[key_] == json_got[key_]
if isinstance(json_expected[key_], list):
assert sorted(json_expected[key_]) == sorted(json_got[key_])
else:
assert json_expected[key_] == json_got[key_]
else:
assert json_expected[key_] in json_got[key_]