Added --no-extended-attributes option to CLI, closes #85
This commit is contained in:
@@ -374,6 +374,28 @@ def test_export_13():
|
||||
assert e.type == type(FileNotFoundError())
|
||||
|
||||
|
||||
def test_export_no_xattr():
|
||||
# test basic export with no_xattr=True
|
||||
# get an unedited image and export it using default filename
|
||||
import os
|
||||
import os.path
|
||||
import tempfile
|
||||
|
||||
import osxphotos
|
||||
|
||||
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||
dest = tempdir.name
|
||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||
photos = photosdb.photos(uuid=[UUID_DICT["export"]])
|
||||
|
||||
filename = photos[0].filename
|
||||
expected_dest = os.path.join(dest, filename)
|
||||
got_dest = photos[0].export(dest, no_xattr=True)[0]
|
||||
|
||||
assert got_dest == expected_dest
|
||||
assert os.path.isfile(got_dest)
|
||||
|
||||
|
||||
def test_dd_to_dms_str_1():
|
||||
import osxphotos
|
||||
|
||||
@@ -517,4 +539,3 @@ def test_xmp_sidecar():
|
||||
|
||||
for line_expected, line_got in zip(xmp_expected_lines, xmp_got_lines):
|
||||
assert line_expected == line_got
|
||||
|
||||
|
||||
@@ -51,3 +51,41 @@ def test_db_is_locked_unlocked():
|
||||
import osxphotos
|
||||
|
||||
assert not osxphotos.utils._db_is_locked(DB_UNLOCKED_10_15)
|
||||
|
||||
|
||||
def test_copy_file_valid():
|
||||
# _copy_file with valid src, dest
|
||||
import os.path
|
||||
import tempfile
|
||||
from osxphotos.utils import _copy_file
|
||||
|
||||
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||
src = "tests/test-images/wedding.jpg"
|
||||
result = _copy_file(src, temp_dir.name)
|
||||
assert result == 0
|
||||
assert os.path.isfile(os.path.join(temp_dir.name, "wedding.jpg"))
|
||||
|
||||
|
||||
def test_copy_file_invalid():
|
||||
# _copy_file with invalid src
|
||||
import tempfile
|
||||
from osxphotos.utils import _copy_file
|
||||
|
||||
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||
src = "tests/test-images/wedding_DOES_NOT_EXIST.jpg"
|
||||
with pytest.raises(Exception) as e:
|
||||
assert _copy_file(src, temp_dir.name)
|
||||
assert e.type == FileNotFoundError
|
||||
|
||||
|
||||
def test_copy_file_norsrc():
|
||||
# _copy_file with --norsrc
|
||||
import os.path
|
||||
import tempfile
|
||||
from osxphotos.utils import _copy_file
|
||||
|
||||
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||
src = "tests/test-images/wedding.jpg"
|
||||
result = _copy_file(src, temp_dir.name, norsrc=True)
|
||||
assert result == 0
|
||||
assert os.path.isfile(os.path.join(temp_dir.name, "wedding.jpg"))
|
||||
|
||||
Reference in New Issue
Block a user