Refactored FileUtil to use copy-on-write no APFS, issue #287

This commit is contained in:
Rhet Turnbull
2020-12-10 20:29:47 -08:00
parent d8de86cb6f
commit ec4b53ed9d
8 changed files with 38 additions and 101 deletions

View File

@@ -414,28 +414,6 @@ 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

View File

@@ -16,7 +16,7 @@ def test_copy_file_valid():
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
src = "tests/test-images/wedding.jpg"
result = FileUtil.copy(src, temp_dir.name)
assert result == 0
assert result
assert os.path.isfile(os.path.join(temp_dir.name, "wedding.jpg"))
@@ -29,20 +29,7 @@ def test_copy_file_invalid():
with pytest.raises(Exception) as e:
src = "tests/test-images/wedding_DOES_NOT_EXIST.jpg"
assert FileUtil.copy(src, temp_dir.name)
assert e.type == FileNotFoundError
def test_copy_file_norsrc():
# copy file with --norsrc
import os.path
import tempfile
from osxphotos.fileutil import FileUtil
temp_dir = tempfile.TemporaryDirectory(prefix="osxphotos_")
src = "tests/test-images/wedding.jpg"
result = FileUtil.copy(src, temp_dir.name, norsrc=True)
assert result == 0
assert os.path.isfile(os.path.join(temp_dir.name, "wedding.jpg"))
assert e.type == OSError
def test_hardlink_file_valid():