Added test for issue #235

This commit is contained in:
Rhet Turnbull
2020-10-18 21:34:50 -07:00
parent a95193aaa4
commit ea68229dda

View File

@@ -20,6 +20,12 @@ NAMES_DICT = {
"heic": "7783E8E6-9CAC-40F3-BE22-81FB7051C266.jpeg",
}
UUID_LIVE_HEIC = "1337F3F6-5C9F-4FC7-80CC-BD9A5B928F72"
NAMES_LIVE_HEIC = [
"1337F3F6-5C9F-4FC7-80CC-BD9A5B928F72.jpeg",
"1337F3F6-5C9F-4FC7-80CC-BD9A5B928F72.mov",
]
@pytest.fixture(scope="module")
def photosdb():
@@ -60,3 +66,33 @@ def test_export_convert_heic_to_jpeg(photosdb):
assert got_dest.is_file()
assert got_dest.suffix == ".jpeg"
assert got_dest.name == NAMES_DICT["heic"]
@pytest.mark.skipif(
"OSXPHOTOS_TEST_EXPORT" not in os.environ,
reason="Skip if not running against author's personal library",
)
def test_export_convert_live_heic_to_jpeg():
# test export with convert_to_jpeg with live heic (issue #235)
# don't have a live HEIC in one of the test libraries so use one from
# my personal library
import os
import pathlib
import tempfile
import osxphotos
photosdb = osxphotos.PhotosDB()
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
dest = tempdir.name
photo = photosdb.get_photo(UUID_LIVE_HEIC)
results = photo.export2(dest, convert_to_jpeg=True, live_photo=True)
for name in NAMES_LIVE_HEIC:
assert f"{tempdir.name}/{name}" in results.exported
for file_ in results.exported:
dest = pathlib.Path(file_)
assert dest.is_file()