Fixed handling of burst image selected/key/default, closes #401 (again)

This commit is contained in:
Rhet Turnbull
2021-04-24 19:43:35 -07:00
parent 48c229b52c
commit 3711b3f7f1
27 changed files with 861 additions and 137 deletions

File diff suppressed because one or more lines are too long

View File

@@ -116,6 +116,12 @@ UUID_DICT = {
UUID_DICT_LOCAL = {
"not_visible": "ABF00253-78E7-4FD6-953B-709307CD489D",
"burst": "44AF1FCA-AC2D-4FA5-B288-E67DC18F9CA8",
"burst_key": "9F90DC00-AAAF-4A05-9A65-61FEEE0D67F2",
"burst_not_key": "38F8F30C-FF6D-49DA-8092-18497F1D6628",
"burst_selected": "38F8F30C-FF6D-49DA-8092-18497F1D6628",
"burst_not_selected": "A385FA13-DF8E-482F-A8C5-970EDDF54C2F",
"burst_default": "964F457D-5FFC-47B9-BEAD-56B0A83FEF63",
"burst_not_default": "A385FA13-DF8E-482F-A8C5-970EDDF54C2F",
}
UUID_PUMPKIN_FARM = [
@@ -890,7 +896,9 @@ def test_export_12(photosdb):
edited_name = pathlib.Path(photos[0].path_edited).name
edited_suffix = pathlib.Path(edited_name).suffix
filename = pathlib.Path(photos[0].original_filename).stem + "_edited" + edited_suffix
filename = (
pathlib.Path(photos[0].original_filename).stem + "_edited" + edited_suffix
)
expected_dest = os.path.join(dest, filename)
got_dest = photos[0].export(dest, edited=True)[0]
@@ -1199,6 +1207,36 @@ def test_visible_burst(photosdb_local):
assert len(photo.burst_photos) == 4
@pytest.mark.skipif(SKIP_TEST, reason="Skip if not running on author's local machine.")
def test_burst_key(photosdb_local):
""" test burst_key """
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_key"])
assert photo.burst_key
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_not_key"])
assert not photo.burst_key
@pytest.mark.skipif(SKIP_TEST, reason="Skip if not running on author's local machine.")
def test_burst_selected(photosdb_local):
""" test burst_selected """
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_selected"])
assert photo.burst_selected
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_not_selected"])
assert not photo.burst_selected
@pytest.mark.skipif(SKIP_TEST, reason="Skip if not running on author's local machine.")
def test_burst_default_pic(photosdb_local):
""" test burst_default_pick"""
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_default"])
assert photo.burst_default_pick
photo = photosdb_local.get_photo(UUID_DICT_LOCAL["burst_not_default"])
assert not photo.burst_default_pick
def test_is_reference(photosdb):
""" test isreference """

View File

@@ -24,14 +24,24 @@ PHOTOS_DB_MOVIES = "tests/Test-Movie-5_0.photoslibrary"
# my personal library which some tests require
PHOTOS_DB_RHET = os.path.expanduser("~/Pictures/Photos Library.photoslibrary")
UUID_BURST_ALBUM = "9F90DC00-AAAF-4A05-9A65-61FEEE0D67F2" # in my personal library
BURST_ALBUM_FILES = [
"IMG_9812.JPG",
"IMG_9813.JPG",
"IMG_9814.JPG",
"IMG_9815.JPG",
"IMG_9816.JPG",
]
UUID_BURST_ALBUM = {
"9F90DC00-AAAF-4A05-9A65-61FEEE0D67F2": [
"TestBurst/IMG_9812.JPG", # in my personal library, IMG_9812.JPG == "9F90DC00-AAAF-4A05-9A65-61FEEE0D67F2"
"TestBurst/IMG_9813.JPG",
"TestBurst/IMG_9814.JPG",
"TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.JPG",
"TestBurst2/IMG_9814.JPG",
],
"38F8F30C-FF6D-49DA-8092-18497F1D6628": [
"TestBurst/IMG_9812.JPG",
"TestBurst/IMG_9813.JPG",
"TestBurst/IMG_9814.JPG", # in my personal library, "38F8F30C-FF6D-49DA-8092-18497F1D6628"
"TestBurst/IMG_9815.JPG",
"TestBurst/IMG_9816.JPG",
"TestBurst2/IMG_9814.JPG",
],
}
UUID_FILE = "tests/uuid_from_file.txt"
@@ -5724,27 +5734,25 @@ def test_export_burst_folder_album():
runner = CliRunner()
cwd = os.getcwd()
# pylint: disable=not-context-manager
with runner.isolated_filesystem():
result = runner.invoke(
export,
[
os.path.join(cwd, PHOTOS_DB_RHET),
".",
"-V",
"--directory",
"{folder_album}",
"--uuid",
UUID_BURST_ALBUM,
"--download-missing",
"--use-photokit",
],
)
assert result.exit_code == 0
folder_album = pathlib.Path("TestBurst")
assert folder_album.is_dir()
for filename in BURST_ALBUM_FILES:
path = folder_album / filename
assert path.is_file()
for uuid in UUID_BURST_ALBUM:
with runner.isolated_filesystem():
result = runner.invoke(
export,
[
os.path.join(cwd, PHOTOS_DB_RHET),
".",
"-V",
"--directory",
"{folder_album}",
"--uuid",
uuid,
"--download-missing",
"--use-photokit",
],
)
assert result.exit_code == 0
files = [str(p) for p in pathlib.Path(".").glob("**/*.JPG")]
assert sorted(files) == sorted(UUID_BURST_ALBUM[uuid])
def test_query_name():

View File

@@ -19,29 +19,34 @@ UUID_DICT = {
UUID_BURSTS = {
"9F90DC00-AAAF-4A05-9A65-61FEEE0D67F2": {
"selected": True,
"filename": "IMAGE_9812.JPG",
"albums": ["TestBurst"],
},
"964F457D-5FFC-47B9-BEAD-56B0A83FEF63": {
"selected": True,
"filename": "IMG_9816.JPG",
"albums": [],
"selected": False,
"filename": "IMG_9812.JPG",
"burst_albums": ["TestBurst"],
"albums": ["TestBurst"]
},
"A385FA13-DF8E-482F-A8C5-970EDDF54C2F": {
"selected": False,
"filename": "IMG_9813.JPG",
"albums": ["TestBurst", "TestBurst2"],
"burst_albums": ["TestBurst"],
"albums": []
},
"38F8F30C-FF6D-49DA-8092-18497F1D6628": {
"selected": True,
"filename": "IMG_9814.JPG",
"albums": ["TestBurst2"],
"burst_albums": ["TestBurst", "TestBurst2"],
"albums": ["TestBurst2"]
},
"E3863443-9EA8-417F-A90B-8F7086623DAD": {
"selected": False,
"filename": "IMG_9815.JPG",
"albums": ["TestBurst", "TestBurst2"],
"burst_albums": ["TestBurst"],
"albums": []
},
"964F457D-5FFC-47B9-BEAD-56B0A83FEF63": {
"selected": True,
"filename": "IMG_9816.JPG",
"burst_albums": ["TestBurst"],
"albums": []
},
}
@@ -193,4 +198,5 @@ def test_burst_albums(photosdb):
photo = photosdb.get_photo(uuid)
assert photo.burst
assert photo.burst_selected == UUID_BURSTS[uuid]["selected"]
assert sorted(photo.burst_albums) == sorted(UUID_BURSTS[uuid]["albums"])
assert sorted(photo.albums) == sorted(UUID_BURSTS[uuid]["albums"])
assert sorted(photo.burst_albums) == sorted(UUID_BURSTS[uuid]["burst_albums"])

View File

@@ -54,7 +54,7 @@ UUID_DICT = {
"burst": {
"uuid": "CD97EC84-71F0-40C6-BAC1-2BABEE305CAC",
"filename": "IMG_8196.JPG",
"burst_selected": 3,
"burst_selected": 4,
"burst_all": 5,
},
}