fixed formatting (#1096)
This commit is contained in:
parent
492e1edb7f
commit
2c80226ec8
@ -21,7 +21,6 @@ from osxphotos.sqlitekvstore import SQLiteKVStore
|
|||||||
|
|
||||||
|
|
||||||
class Latitude(click.ParamType):
|
class Latitude(click.ParamType):
|
||||||
|
|
||||||
name = "Latitude"
|
name = "Latitude"
|
||||||
|
|
||||||
def convert(self, value, param, ctx):
|
def convert(self, value, param, ctx):
|
||||||
@ -37,7 +36,6 @@ class Latitude(click.ParamType):
|
|||||||
|
|
||||||
|
|
||||||
class Longitude(click.ParamType):
|
class Longitude(click.ParamType):
|
||||||
|
|
||||||
name = "Longitude"
|
name = "Longitude"
|
||||||
|
|
||||||
def convert(self, value, param, ctx):
|
def convert(self, value, param, ctx):
|
||||||
|
|||||||
@ -23,10 +23,7 @@ to your function. You can then do whatever you want with the photos.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos.cli import (
|
from osxphotos.cli import selection_command, verbose
|
||||||
selection_command,
|
|
||||||
verbose,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@selection_command
|
@selection_command
|
||||||
|
|||||||
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import osxphotos
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument("album1")
|
@click.argument("album1")
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import osxphotos
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
db = osxphotos.utils.get_system_library_path()
|
db = osxphotos.utils.get_system_library_path()
|
||||||
|
|||||||
@ -77,7 +77,9 @@ def place_folder(photo: osxphotos.PhotoInfo) -> str:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def photos_folders(photo: osxphotos.PhotoInfo, options: osxphotos.phototemplate.RenderOptions, **kwargs) -> Union[List, str]:
|
def photos_folders(
|
||||||
|
photo: osxphotos.PhotoInfo, options: osxphotos.phototemplate.RenderOptions, **kwargs
|
||||||
|
) -> Union[List, str]:
|
||||||
"""template function for use with --directory to export photos in a folder structure similar to Photos
|
"""template function for use with --directory to export photos in a folder structure similar to Photos
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@ -29,7 +29,9 @@ def main():
|
|||||||
exported = photo.export(tempdir.name, use_photos_export=True, timeout=300)
|
exported = photo.export(tempdir.name, use_photos_export=True, timeout=300)
|
||||||
if photo.hasadjustments:
|
if photo.hasadjustments:
|
||||||
exported.extend(
|
exported.extend(
|
||||||
photo.export(tempdir.name, use_photos_export=True, edited=True, timeout=300)
|
photo.export(
|
||||||
|
tempdir.name, use_photos_export=True, edited=True, timeout=300
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for filename in exported:
|
for filename in exported:
|
||||||
print(f"Removing temporary file {filename}")
|
print(f"Removing temporary file {filename}")
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import time
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos.cli import get_photos_db, _list_libraries
|
from osxphotos.cli import _list_libraries, get_photos_db
|
||||||
|
|
||||||
|
|
||||||
def show(photo):
|
def show(photo):
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
""" Example function for use with osxphotos import --post-function option """
|
""" Example function for use with osxphotos import --post-function option """
|
||||||
|
|
||||||
import typing as t
|
|
||||||
import photoscript
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import typing as t
|
||||||
|
|
||||||
|
import photoscript
|
||||||
|
|
||||||
from osxphotos.cli.import_cli import ReportRecord
|
from osxphotos.cli.import_cli import ReportRecord
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import os.path
|
|||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
db = os.path.expanduser("~/Pictures/Photos Library.photoslibrary")
|
db = os.path.expanduser("~/Pictures/Photos Library.photoslibrary")
|
||||||
photosdb = osxphotos.PhotosDB(db)
|
photosdb = osxphotos.PhotosDB(db)
|
||||||
@ -18,8 +19,11 @@ def main():
|
|||||||
photos = photosdb.photos(keywords=["Foo"], persons=["John Smith"])
|
photos = photosdb.photos(keywords=["Foo"], persons=["John Smith"])
|
||||||
|
|
||||||
# find all photos that include Alice Smith but do not contain the keyword Bar
|
# find all photos that include Alice Smith but do not contain the keyword Bar
|
||||||
photos = [p for p in photosdb.photos(persons=["Alice Smith"])
|
photos = [
|
||||||
if p not in photosdb.photos(keywords=["Bar"]) ]
|
p
|
||||||
|
for p in photosdb.photos(persons=["Alice Smith"])
|
||||||
|
if p not in photosdb.photos(keywords=["Bar"])
|
||||||
|
]
|
||||||
for p in photos:
|
for p in photos:
|
||||||
print(
|
print(
|
||||||
p.uuid,
|
p.uuid,
|
||||||
@ -34,5 +38,6 @@ def main():
|
|||||||
p.path,
|
p.path,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
def myfilter(values: List[str]) -> List[str]:
|
def myfilter(values: List[str]) -> List[str]:
|
||||||
"""Custom filter to append "foo-" to template value"""
|
"""Custom filter to append "foo-" to template value"""
|
||||||
values = ["foo-" + val for val in values]
|
values = ["foo-" + val for val in values]
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import sys
|
|||||||
from rich import print
|
from rich import print
|
||||||
from rich.traceback import install as install_traceback
|
from rich.traceback import install as install_traceback
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
|
||||||
from osxphotos.debug import (
|
from osxphotos.debug import (
|
||||||
debug_breakpoint,
|
debug_breakpoint,
|
||||||
debug_watch,
|
debug_watch,
|
||||||
@ -14,6 +13,7 @@ from osxphotos.debug import (
|
|||||||
set_debug,
|
set_debug,
|
||||||
wrap_function,
|
wrap_function,
|
||||||
)
|
)
|
||||||
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
# apply any debug functions
|
# apply any debug functions
|
||||||
# need to do this before importing anything else so that the debug functions
|
# need to do this before importing anything else so that the debug functions
|
||||||
|
|||||||
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import functools
|
|
||||||
from typing import Any, Callable
|
|
||||||
import click
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import functools
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
from typing import Any, Callable
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
from ..utils import is_macos
|
from ..utils import is_macos
|
||||||
from .common import OSXPHOTOS_HIDDEN, print_version
|
from .common import OSXPHOTOS_HIDDEN, print_version
|
||||||
|
|||||||
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import objc
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import objc
|
||||||
|
|
||||||
def theme():
|
def theme():
|
||||||
with objc.autorelease_pool():
|
with objc.autorelease_pool():
|
||||||
|
|||||||
@ -19,14 +19,14 @@ from osxphotos.export_db_utils import (
|
|||||||
export_db_backup,
|
export_db_backup,
|
||||||
export_db_check_signatures,
|
export_db_check_signatures,
|
||||||
export_db_get_errors,
|
export_db_get_errors,
|
||||||
|
export_db_get_last_library,
|
||||||
export_db_get_last_run,
|
export_db_get_last_run,
|
||||||
export_db_get_version,
|
export_db_get_version,
|
||||||
|
export_db_migrate_photos_library,
|
||||||
export_db_save_config_to_file,
|
export_db_save_config_to_file,
|
||||||
export_db_touch_files,
|
export_db_touch_files,
|
||||||
export_db_update_signatures,
|
export_db_update_signatures,
|
||||||
export_db_vacuum,
|
export_db_vacuum,
|
||||||
export_db_migrate_photos_library,
|
|
||||||
export_db_get_last_library,
|
|
||||||
)
|
)
|
||||||
from osxphotos.utils import pluralize
|
from osxphotos.utils import pluralize
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"""query command for osxphotos CLI"""
|
"""query command for osxphotos CLI"""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import click
|
|||||||
from osxphotos._constants import UUID_PATTERN
|
from osxphotos._constants import UUID_PATTERN
|
||||||
from osxphotos.export_db_utils import get_uuid_for_filepath
|
from osxphotos.export_db_utils import get_uuid_for_filepath
|
||||||
from osxphotos.photosdb.photosdb_utils import get_photos_library_version
|
from osxphotos.photosdb.photosdb_utils import get_photos_library_version
|
||||||
from osxphotos.utils import get_last_library_path, assert_macos
|
from osxphotos.utils import assert_macos, get_last_library_path
|
||||||
|
|
||||||
assert_macos()
|
assert_macos()
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ from osxphotos.utils import assert_macos, noop, pluralize
|
|||||||
assert_macos()
|
assert_macos()
|
||||||
|
|
||||||
from photoscript import PhotosLibrary
|
from photoscript import PhotosLibrary
|
||||||
|
|
||||||
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
from osxphotos.photosalbum import PhotosAlbumPhotoScript
|
||||||
|
|
||||||
from .cli_params import THEME_OPTION, TIMESTAMP_OPTION, VERBOSE_OPTION
|
from .cli_params import THEME_OPTION, TIMESTAMP_OPTION, VERBOSE_OPTION
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
"""about command for osxphotos CLI"""
|
"""about command for osxphotos CLI"""
|
||||||
|
|
||||||
import click
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import click
|
||||||
|
import packaging
|
||||||
|
|
||||||
from osxphotos._constants import OSXPHOTOS_URL
|
from osxphotos._constants import OSXPHOTOS_URL
|
||||||
from osxphotos._version import __version__
|
from osxphotos._version import __version__
|
||||||
|
|
||||||
from .common import get_latest_version
|
from .common import get_latest_version
|
||||||
import packaging
|
|
||||||
|
|
||||||
|
|
||||||
@click.command(name="version")
|
@click.command(name="version")
|
||||||
|
|||||||
@ -12,6 +12,7 @@ from .utils import assert_macos, noop
|
|||||||
assert_macos()
|
assert_macos()
|
||||||
|
|
||||||
from photoscript import Photo
|
from photoscript import Photo
|
||||||
|
|
||||||
from .exif_datetime_updater import get_exif_date_time_offset
|
from .exif_datetime_updater import get_exif_date_time_offset
|
||||||
from .phototz import PhotoTimeZone
|
from .phototz import PhotoTimeZone
|
||||||
|
|
||||||
|
|||||||
@ -13,8 +13,8 @@ from wurlitzer import pipes
|
|||||||
from .utils import is_macos
|
from .utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import objc
|
|
||||||
import Metal
|
import Metal
|
||||||
|
import objc
|
||||||
import Quartz
|
import Quartz
|
||||||
from Cocoa import NSURL
|
from Cocoa import NSURL
|
||||||
from Foundation import NSDictionary
|
from Foundation import NSDictionary
|
||||||
|
|||||||
@ -101,7 +101,9 @@ class PhotosAlbum:
|
|||||||
try:
|
try:
|
||||||
photos.append(photoscript.Photo(p.uuid))
|
photos.append(photoscript.Photo(p.uuid))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error creating Photo object for photo {self._format_uuid(p.uuid)}: {e}")
|
print(
|
||||||
|
f"Error creating Photo object for photo {self._format_uuid(p.uuid)}: {e}"
|
||||||
|
)
|
||||||
self.verbose(
|
self.verbose(
|
||||||
f"Error creating Photo object for photo {self._format_uuid(p.uuid)}: {e}"
|
f"Error creating Photo object for photo {self._format_uuid(p.uuid)}: {e}"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,4 +4,4 @@ Processes a Photos.app library database to extract information about photos
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from .photosdb import PhotosDB
|
from .photosdb import PhotosDB
|
||||||
from .photosdb_utils import get_db_version, get_db_model_version, get_model_version
|
from .photosdb_utils import get_db_model_version, get_db_version, get_model_version
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import datetime
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from .._constants import _DB_TABLE_NAMES, _PHOTOS_4_VERSION, TIME_DELTA
|
from .._constants import _DB_TABLE_NAMES, _PHOTOS_4_VERSION, TIME_DELTA
|
||||||
from ..utils import normalize_unicode
|
|
||||||
from ..sqlite_utils import sqlite_open_ro
|
from ..sqlite_utils import sqlite_open_ro
|
||||||
|
from ..utils import normalize_unicode
|
||||||
|
|
||||||
|
|
||||||
def _process_comments(self):
|
def _process_comments(self):
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .._constants import _DB_TABLE_NAMES, _PHOTOS_4_VERSION
|
from .._constants import _DB_TABLE_NAMES, _PHOTOS_4_VERSION
|
||||||
from ..sqlite_utils import sqlite_open_ro, sqlite_db_is_locked
|
from ..sqlite_utils import sqlite_db_is_locked, sqlite_open_ro
|
||||||
from .photosdb_utils import get_db_version
|
from .photosdb_utils import get_db_version
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from .._constants import _DB_TABLE_NAMES
|
from .._constants import _DB_TABLE_NAMES
|
||||||
from ..sqlite_utils import sqlite_open_ro
|
from ..sqlite_utils import sqlite_open_ro
|
||||||
|
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from osxphotos.photosdb import PhotosDB
|
from osxphotos.photosdb import PhotosDB
|
||||||
|
|
||||||
|
|||||||
@ -61,9 +61,9 @@ from ..rich_utils import add_rich_markup_tag
|
|||||||
from ..sqlite_utils import sqlite_db_is_locked, sqlite_open_ro
|
from ..sqlite_utils import sqlite_db_is_locked, sqlite_open_ro
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
_check_file_exists,
|
_check_file_exists,
|
||||||
is_macos,
|
|
||||||
get_macos_version,
|
|
||||||
get_last_library_path,
|
get_last_library_path,
|
||||||
|
get_macos_version,
|
||||||
|
is_macos,
|
||||||
noop,
|
noop,
|
||||||
normalize_unicode,
|
normalize_unicode,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
""" ScoreInfo class to expose computed score info from the library """
|
""" ScoreInfo class to expose computed score info from the library """
|
||||||
|
|
||||||
from dataclasses import dataclass, asdict
|
from dataclasses import asdict, dataclass
|
||||||
|
|
||||||
from ._constants import _PHOTOS_4_VERSION
|
from ._constants import _PHOTOS_4_VERSION
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
"""Utilities for working with datetimes"""
|
"""Utilities for working with datetimes"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
def utc_offset_string_to_seconds(utc_offset: str) -> int:
|
def utc_offset_string_to_seconds(utc_offset: str) -> int:
|
||||||
|
|||||||
@ -24,7 +24,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from .utils import assert_macos, is_macos, get_macos_version
|
from .utils import assert_macos, get_macos_version, is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import CoreServices
|
import CoreServices
|
||||||
|
|||||||
@ -18,7 +18,6 @@ if is_macos:
|
|||||||
|
|
||||||
from osxphotos.exiftool import _ExifToolProc
|
from osxphotos.exiftool import _ExifToolProc
|
||||||
|
|
||||||
|
|
||||||
# run timewarp tests (configured with --timewarp)
|
# run timewarp tests (configured with --timewarp)
|
||||||
TEST_TIMEWARP = False
|
TEST_TIMEWARP = False
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos.photoexporter import PhotoExporter, ExportOptions
|
from osxphotos.photoexporter import ExportOptions, PhotoExporter
|
||||||
|
|
||||||
PHOTOS_DB_15_7 = "./tests/Test-10.15.7.photoslibrary/database/photos.db"
|
PHOTOS_DB_15_7 = "./tests/Test-10.15.7.photoslibrary/database/photos.db"
|
||||||
PHOTOS_DB_14_6 = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
PHOTOS_DB_14_6 = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
||||||
@ -92,9 +92,7 @@ def generate_sidecars(dbname, uuid_dict):
|
|||||||
|
|
||||||
# ignore_date_modified
|
# ignore_date_modified
|
||||||
sidecar = str(pathlib.Path(SIDECAR_DIR) / f"{uuid}_ignore_date_modified.json")
|
sidecar = str(pathlib.Path(SIDECAR_DIR) / f"{uuid}_ignore_date_modified.json")
|
||||||
json_ = exporter.exiftool_json_sidecar(
|
json_ = exporter.exiftool_json_sidecar(ExportOptions(ignore_date_modified=True))
|
||||||
ExportOptions(ignore_date_modified=True)
|
|
||||||
)
|
|
||||||
with open(sidecar, "w") as file:
|
with open(sidecar, "w") as file:
|
||||||
file.write(json_)
|
file.write(json_)
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
||||||
def myfilter(values: List[str]) -> List[str]:
|
def myfilter(values: List[str]) -> List[str]:
|
||||||
"""Custom filter to append "foo-" to template value"""
|
"""Custom filter to append "foo-" to template value"""
|
||||||
values = ["foo-" + val for val in values]
|
values = ["foo-" + val for val in values]
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,6 @@ def test_photos_version(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_persons(photosdb):
|
def test_persons(photosdb):
|
||||||
|
|
||||||
assert "Katie" in photosdb.persons
|
assert "Katie" in photosdb.persons
|
||||||
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
assert collections.Counter(PERSONS) == collections.Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON, AlbumSortOrder
|
from osxphotos._constants import _UNKNOWN_PERSON, AlbumSortOrder
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.15.7.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.15.7.photoslibrary/database/photos.db"
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.13.6.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.13.6.photoslibrary/database/photos.db"
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
||||||
|
|||||||
@ -226,6 +226,7 @@ def test_init4():
|
|||||||
# test invalid db
|
# test invalid db
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
(bad_db, bad_db_name) = tempfile.mkstemp(suffix=".db", prefix="osxphotos-")
|
(bad_db, bad_db_name) = tempfile.mkstemp(suffix=".db", prefix="osxphotos-")
|
||||||
@ -606,7 +607,6 @@ def test_keyword_2(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_keyword_not_in_album(photosdb):
|
def test_keyword_not_in_album(photosdb):
|
||||||
|
|
||||||
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
||||||
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
||||||
photos2 = photosdb.photos(keywords=["Kids"])
|
photos2 = photosdb.photos(keywords=["Kids"])
|
||||||
@ -1024,6 +1024,7 @@ def test_date_invalid():
|
|||||||
"""Test date is invalid"""
|
"""Test date is invalid"""
|
||||||
# doesn't run correctly with the module-level fixture
|
# doesn't run correctly with the module-level fixture
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
# UUID_DICT["date_invalid"] has an invalid date that's
|
# UUID_DICT["date_invalid"] has an invalid date that's
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import pytest
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
from osxphotos.photoexporter import PhotoExporter
|
from osxphotos.photoexporter import PhotoExporter
|
||||||
from osxphotos.utils import is_macos, get_macos_version
|
from osxphotos.utils import get_macos_version, is_macos
|
||||||
|
|
||||||
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
||||||
SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "15"
|
SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "15"
|
||||||
|
|||||||
@ -14,9 +14,9 @@ import subprocess
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from bitmath import contextlib
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from bitmath import contextlib
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|||||||
@ -4,8 +4,10 @@ import pytest
|
|||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import photoscript
|
import photoscript
|
||||||
|
|
||||||
from osxphotos.cli.add_locations import add_locations
|
from osxphotos.cli.add_locations import add_locations
|
||||||
else:
|
else:
|
||||||
pytest.skip(allow_module_level=True)
|
pytest.skip(allow_module_level=True)
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import pytest
|
|||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import photoscript
|
import photoscript
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -24,6 +24,7 @@ TEST_RUN_SCRIPT = "examples/cli_example_1.py"
|
|||||||
def runner() -> CliRunner:
|
def runner() -> CliRunner:
|
||||||
return CliRunner()
|
return CliRunner()
|
||||||
|
|
||||||
|
|
||||||
from osxphotos.cli import (
|
from osxphotos.cli import (
|
||||||
about,
|
about,
|
||||||
albums,
|
albums,
|
||||||
@ -43,7 +44,6 @@ from osxphotos.cli import (
|
|||||||
tutorial,
|
tutorial,
|
||||||
version,
|
version,
|
||||||
)
|
)
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
@ -72,7 +72,8 @@ def test_about(runner: CliRunner):
|
|||||||
places,
|
places,
|
||||||
tutorial,
|
tutorial,
|
||||||
version,
|
version,
|
||||||
] + ([uuid] if is_macos else []),
|
]
|
||||||
|
+ ([uuid] if is_macos else []),
|
||||||
)
|
)
|
||||||
def test_cli_comands(runner: CliRunner, command: Callable[..., Any]):
|
def test_cli_comands(runner: CliRunner, command: Callable[..., Any]):
|
||||||
with runner.isolated_filesystem():
|
with runner.isolated_filesystem():
|
||||||
|
|||||||
@ -13,6 +13,7 @@ from osxphotos.utils import is_macos
|
|||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import photoscript
|
import photoscript
|
||||||
|
|
||||||
from osxphotos.cli.batch_edit import batch_edit
|
from osxphotos.cli.batch_edit import batch_edit
|
||||||
else:
|
else:
|
||||||
pytest.skip(allow_module_level=True)
|
pytest.skip(allow_module_level=True)
|
||||||
|
|||||||
@ -96,6 +96,7 @@ def test_dump_field(photos):
|
|||||||
for photo in photos:
|
for photo in photos:
|
||||||
assert f"{photo.uuid},{photo.original_filename}" in result.output
|
assert f"{photo.uuid},{photo.original_filename}" in result.output
|
||||||
|
|
||||||
|
|
||||||
def test_dump_field_json(photos):
|
def test_dump_field_json(photos):
|
||||||
"""Test osxphotos dump --field --jso"""
|
"""Test osxphotos dump --field --jso"""
|
||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from tempfile import TemporaryDirectory
|
|||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from pytest import MonkeyPatch, approx
|
from pytest import MonkeyPatch, approx
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ from tests.conftest import get_os_version
|
|||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
from photoscript import Photo
|
from photoscript import Photo
|
||||||
|
|
||||||
from osxphotos.cli.import_cli import import_cli
|
from osxphotos.cli.import_cli import import_cli
|
||||||
else:
|
else:
|
||||||
pytest.skip(allow_module_level=True)
|
pytest.skip(allow_module_level=True)
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
""" Test custom click paramater types used by osxphotos CLI"""
|
""" Test custom click paramater types used by osxphotos CLI"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from bitmath import MB
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from bitmath import MB
|
||||||
from osxphotos.timezones import Timezone
|
|
||||||
|
|
||||||
from click.exceptions import BadParameter
|
from click.exceptions import BadParameter
|
||||||
|
|
||||||
from osxphotos.cli.param_types import (
|
from osxphotos.cli.param_types import (
|
||||||
@ -21,6 +18,7 @@ from osxphotos.cli.param_types import (
|
|||||||
TimeString,
|
TimeString,
|
||||||
UTCOffset,
|
UTCOffset,
|
||||||
)
|
)
|
||||||
|
from osxphotos.timezones import Timezone
|
||||||
|
|
||||||
|
|
||||||
def test_date_offset():
|
def test_date_offset():
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
"""Test osxphotos sync command"""
|
"""Test osxphotos sync command"""
|
||||||
|
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
import photoscript
|
import photoscript
|
||||||
|
|
||||||
from osxphotos.cli.sync import sync
|
from osxphotos.cli.sync import sync
|
||||||
else:
|
else:
|
||||||
pytest.skip(allow_module_level=True)
|
pytest.skip(allow_module_level=True)
|
||||||
|
|||||||
@ -3,13 +3,12 @@
|
|||||||
import re
|
import re
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
|
||||||
from osxphotos.cli.verbose import (
|
from osxphotos.cli.verbose import (
|
||||||
|
_reset_verbose_globals,
|
||||||
get_verbose_level,
|
get_verbose_level,
|
||||||
set_verbose_level,
|
set_verbose_level,
|
||||||
verbose,
|
verbose,
|
||||||
verbose_print,
|
verbose_print,
|
||||||
_reset_verbose_globals,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ def test_datetime_formatter_1():
|
|||||||
"""Test DateTimeFormatter"""
|
"""Test DateTimeFormatter"""
|
||||||
import datetime
|
import datetime
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from osxphotos.datetime_formatter import DateTimeFormatter
|
from osxphotos.datetime_formatter import DateTimeFormatter
|
||||||
|
|
||||||
setlocale(locale.LC_ALL, "en_US")
|
setlocale(locale.LC_ALL, "en_US")
|
||||||
@ -32,6 +33,7 @@ def test_datetime_formatter_2():
|
|||||||
"""Test DateTimeFormatter with hour > 12"""
|
"""Test DateTimeFormatter with hour > 12"""
|
||||||
import datetime
|
import datetime
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from osxphotos.datetime_formatter import DateTimeFormatter
|
from osxphotos.datetime_formatter import DateTimeFormatter
|
||||||
|
|
||||||
setlocale(locale.LC_ALL, "en_US")
|
setlocale(locale.LC_ALL, "en_US")
|
||||||
@ -56,6 +58,7 @@ def test_datetime_formatter_3():
|
|||||||
"""Test DateTimeFormatter zero-padding"""
|
"""Test DateTimeFormatter zero-padding"""
|
||||||
import datetime
|
import datetime
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from osxphotos.datetime_formatter import DateTimeFormatter
|
from osxphotos.datetime_formatter import DateTimeFormatter
|
||||||
|
|
||||||
setlocale(locale.LC_ALL, "en_US")
|
setlocale(locale.LC_ALL, "en_US")
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from datetime import date, timezone
|
from datetime import date, timezone
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos.datetime_utils import *
|
from osxphotos.datetime_utils import *
|
||||||
|
|||||||
@ -30,25 +30,28 @@ def test_db_version():
|
|||||||
|
|
||||||
|
|
||||||
def test_persons():
|
def test_persons():
|
||||||
import osxphotos
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert photosdb.persons == []
|
assert photosdb.persons == []
|
||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
import osxphotos
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert photosdb.keywords == []
|
assert photosdb.keywords == []
|
||||||
|
|
||||||
|
|
||||||
def test_album_names():
|
def test_album_names():
|
||||||
import osxphotos
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert photosdb.albums == []
|
assert photosdb.albums == []
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos.exiftool import get_exiftool_path
|
from osxphotos.exiftool import get_exiftool_path
|
||||||
|
|
||||||
TEST_FILE_ONE_KEYWORD = "tests/test-images/wedding.jpg"
|
TEST_FILE_ONE_KEYWORD = "tests/test-images/wedding.jpg"
|
||||||
@ -131,6 +132,7 @@ def test_setvalue_1():
|
|||||||
# test setting a tag value
|
# test setting a tag value
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -147,6 +149,7 @@ def test_setvalue_cache():
|
|||||||
# test setting a tag value doesn't affect cached value
|
# test setting a tag value doesn't affect cached value
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -174,6 +177,7 @@ def test_setvalue_context_manager():
|
|||||||
# test setting a tag value as context manager
|
# test setting a tag value as context manager
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -190,6 +194,7 @@ def test_flags():
|
|||||||
# test that flags raise error
|
# test that flags raise error
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -207,6 +212,7 @@ def test_clear_value():
|
|||||||
# test clearing a tag value
|
# test clearing a tag value
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -224,6 +230,7 @@ def test_addvalues_1():
|
|||||||
# test setting a tag value
|
# test setting a tag value
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
from osxphotos.fileutil import FileUtil
|
from osxphotos.fileutil import FileUtil
|
||||||
|
|
||||||
@ -276,9 +283,10 @@ def test_as_dict_no_tag_groups():
|
|||||||
|
|
||||||
|
|
||||||
def test_json():
|
def test_json():
|
||||||
import osxphotos.exiftool
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import osxphotos.exiftool
|
||||||
|
|
||||||
exif1 = osxphotos.exiftool.ExifToolCaching(TEST_FILE_ONE_KEYWORD)
|
exif1 = osxphotos.exiftool.ExifToolCaching(TEST_FILE_ONE_KEYWORD)
|
||||||
exifdata = json.loads(exif1.json())
|
exifdata = json.loads(exif1.json())
|
||||||
assert exifdata[0]["XMP:TagsList"] == "wedding"
|
assert exifdata[0]["XMP:TagsList"] == "wedding"
|
||||||
|
|||||||
@ -357,7 +357,6 @@ def test_export_13(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_dd_to_dms_str_1():
|
def test_dd_to_dms_str_1():
|
||||||
|
|
||||||
lat_str, lon_str = dd_to_dms_str(
|
lat_str, lon_str = dd_to_dms_str(
|
||||||
34.559331096, 69.206499174
|
34.559331096, 69.206499174
|
||||||
) # Kabul, 34°33'33.59" N 69°12'23.40" E
|
) # Kabul, 34°33'33.59" N 69°12'23.40" E
|
||||||
@ -367,7 +366,6 @@ def test_dd_to_dms_str_1():
|
|||||||
|
|
||||||
|
|
||||||
def test_dd_to_dms_str_2():
|
def test_dd_to_dms_str_2():
|
||||||
|
|
||||||
lat_str, lon_str = dd_to_dms_str(
|
lat_str, lon_str = dd_to_dms_str(
|
||||||
-34.601997592, -58.375665164
|
-34.601997592, -58.375665164
|
||||||
) # Buenos Aires, 34°36'7.19" S 58°22'32.39" W
|
) # Buenos Aires, 34°36'7.19" S 58°22'32.39" W
|
||||||
@ -377,7 +375,6 @@ def test_dd_to_dms_str_2():
|
|||||||
|
|
||||||
|
|
||||||
def test_dd_to_dms_str_3():
|
def test_dd_to_dms_str_3():
|
||||||
|
|
||||||
lat_str, lon_str = dd_to_dms_str(
|
lat_str, lon_str = dd_to_dms_str(
|
||||||
-1.2666656, 36.7999968
|
-1.2666656, 36.7999968
|
||||||
) # Nairobi, 1°15'60.00" S 36°47'59.99" E
|
) # Nairobi, 1°15'60.00" S 36°47'59.99" E
|
||||||
@ -387,7 +384,6 @@ def test_dd_to_dms_str_3():
|
|||||||
|
|
||||||
|
|
||||||
def test_dd_to_dms_str_4():
|
def test_dd_to_dms_str_4():
|
||||||
|
|
||||||
lat_str, lon_str = dd_to_dms_str(
|
lat_str, lon_str = dd_to_dms_str(
|
||||||
38.889248, -77.050636
|
38.889248, -77.050636
|
||||||
) # DC: 38° 53' 21.2928" N, 77° 3' 2.2896" W
|
) # DC: 38° 53' 21.2928" N, 77° 3' 2.2896" W
|
||||||
@ -397,7 +393,6 @@ def test_dd_to_dms_str_4():
|
|||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar(photosdb):
|
def test_exiftool_json_sidecar(photosdb):
|
||||||
|
|
||||||
uuid = EXIF_JSON_UUID
|
uuid = EXIF_JSON_UUID
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -411,7 +406,6 @@ def test_exiftool_json_sidecar(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar_ignore_date_modified(photosdb):
|
def test_exiftool_json_sidecar_ignore_date_modified(photosdb):
|
||||||
|
|
||||||
uuid = EXIF_JSON_UUID
|
uuid = EXIF_JSON_UUID
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -469,9 +463,7 @@ def test_exiftool_json_sidecar_keyword_template_long(capsys, photosdb):
|
|||||||
assert json_got[k] == v
|
assert json_got[k] == v
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar_keyword_template(photosdb):
|
def test_exiftool_json_sidecar_keyword_template(photosdb):
|
||||||
|
|
||||||
uuid = EXIF_JSON_UUID
|
uuid = EXIF_JSON_UUID
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -488,7 +480,6 @@ def test_exiftool_json_sidecar_keyword_template(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar_use_persons_keyword(photosdb):
|
def test_exiftool_json_sidecar_use_persons_keyword(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -506,7 +497,6 @@ def test_exiftool_json_sidecar_use_persons_keyword(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar_use_albums_keywords(photosdb):
|
def test_exiftool_json_sidecar_use_albums_keywords(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -550,7 +540,6 @@ def test_xmp_sidecar_is_valid(tmp_path, photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar(photosdb):
|
def test_xmp_sidecar(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photos = photosdb.photos(uuid=[uuid])
|
photos = photosdb.photos(uuid=[uuid])
|
||||||
|
|
||||||
@ -575,7 +564,6 @@ def test_xmp_sidecar_extension(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar_use_persons_keyword(photosdb):
|
def test_xmp_sidecar_use_persons_keyword(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -589,7 +577,6 @@ def test_xmp_sidecar_use_persons_keyword(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar_use_albums_keyword(photosdb):
|
def test_xmp_sidecar_use_albums_keyword(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -616,7 +603,6 @@ def test_xmp_sidecar_gps(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar_keyword_template(photosdb):
|
def test_xmp_sidecar_keyword_template(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["location"]
|
uuid = UUID_DICT["location"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
from osxphotos.utils import is_macos, get_macos_version
|
from osxphotos.utils import get_macos_version, is_macos
|
||||||
|
|
||||||
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
||||||
SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "15"
|
SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "15"
|
||||||
@ -123,6 +124,7 @@ def test_export_edited(photosdb):
|
|||||||
|
|
||||||
def test_export_edited_exiftool(photosdb):
|
def test_export_edited_exiftool(photosdb):
|
||||||
# test export edited file
|
# test export edited file
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import pathlib
|
import pathlib
|
||||||
@ -131,8 +133,6 @@ def test_export_edited_exiftool(photosdb):
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
import osxphotos.exiftool
|
import osxphotos.exiftool
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||||
dest = tempdir.name
|
dest = tempdir.name
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["has_adjustments"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["has_adjustments"]])
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import shutil
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|||||||
@ -330,7 +330,6 @@ def test_export_13(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_exiftool_json_sidecar(photosdb):
|
def test_exiftool_json_sidecar(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["location"]
|
uuid = UUID_DICT["location"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -344,7 +343,6 @@ def test_exiftool_json_sidecar(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar(photosdb):
|
def test_xmp_sidecar(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
@ -357,7 +355,6 @@ def test_xmp_sidecar(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_xmp_sidecar_keyword_template(photosdb):
|
def test_xmp_sidecar_keyword_template(photosdb):
|
||||||
|
|
||||||
uuid = UUID_DICT["xmp"]
|
uuid = UUID_DICT["xmp"]
|
||||||
photo = photosdb.get_photo(uuid)
|
photo = photosdb.get_photo(uuid)
|
||||||
|
|
||||||
|
|||||||
@ -66,9 +66,9 @@ def test_export_edited_name():
|
|||||||
# export edited file with name provided
|
# export edited file with name provided
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
@ -109,10 +109,10 @@ def test_export_edited_wrong_suffix():
|
|||||||
# should produce a warning via logging.warning
|
# should produce a warning via logging.warning
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
""" test ExportResults class """
|
""" test ExportResults class """
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos.photoexporter import ExportResults
|
from osxphotos.photoexporter import ExportResults
|
||||||
|
|
||||||
EXPORT_RESULT_ATTRIBUTES = ExportResults().attributes
|
EXPORT_RESULT_ATTRIBUTES = ExportResults().attributes
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.13.6.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.13.6.photoslibrary/database/photos.db"
|
||||||
|
|||||||
@ -32,6 +32,7 @@ def test_image_converter():
|
|||||||
"""test conversion of different image types"""
|
"""test conversion of different image types"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from osxphotos.imageconverter import ImageConverter
|
from osxphotos.imageconverter import ImageConverter
|
||||||
|
|
||||||
converter = ImageConverter()
|
converter = ImageConverter()
|
||||||
@ -53,6 +54,7 @@ def test_image_converter_compression_quality():
|
|||||||
"""test conversion of different image types with custom compression quality"""
|
"""test conversion of different image types with custom compression quality"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from osxphotos.imageconverter import ImageConverter
|
from osxphotos.imageconverter import ImageConverter
|
||||||
|
|
||||||
converter = ImageConverter()
|
converter = ImageConverter()
|
||||||
@ -72,6 +74,7 @@ def test_image_converter_bad_compression_quality():
|
|||||||
"""test illegal compression quality"""
|
"""test illegal compression quality"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from osxphotos.imageconverter import ImageConverter
|
from osxphotos.imageconverter import ImageConverter
|
||||||
|
|
||||||
converter = ImageConverter()
|
converter = ImageConverter()
|
||||||
@ -89,7 +92,8 @@ def test_image_converter_bad_file():
|
|||||||
"""Try to convert a file that's not an image"""
|
"""Try to convert a file that's not an image"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
from osxphotos.imageconverter import ImageConverter, ImageConversionError
|
|
||||||
|
from osxphotos.imageconverter import ImageConversionError, ImageConverter
|
||||||
|
|
||||||
converter = ImageConverter()
|
converter = ImageConverter()
|
||||||
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
tempdir = tempfile.TemporaryDirectory(prefix="osxphotos_")
|
||||||
@ -104,6 +108,7 @@ def test_image_converter_missing_file():
|
|||||||
"""Try to convert a file that's not an image"""
|
"""Try to convert a file that's not an image"""
|
||||||
import pathlib
|
import pathlib
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from osxphotos.imageconverter import ImageConverter
|
from osxphotos.imageconverter import ImageConverter
|
||||||
|
|
||||||
converter = ImageConverter()
|
converter = ImageConverter()
|
||||||
@ -113,4 +118,3 @@ def test_image_converter_missing_file():
|
|||||||
outfile = pathlib.Path(tempdir.name) / f"{imgfile.stem}.jpeg"
|
outfile = pathlib.Path(tempdir.name) / f"{imgfile.stem}.jpeg"
|
||||||
with pytest.raises(FileNotFoundError):
|
with pytest.raises(FileNotFoundError):
|
||||||
converter.write_jpeg(imgfile, outfile)
|
converter.write_jpeg(imgfile, outfile)
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ UUID_DICT = {
|
|||||||
def photosdb():
|
def photosdb():
|
||||||
return osxphotos.PhotosDB(dbfile=PHOTOS_DB_CLOUD)
|
return osxphotos.PhotosDB(dbfile=PHOTOS_DB_CLOUD)
|
||||||
|
|
||||||
|
|
||||||
def test_incloud(photosdb):
|
def test_incloud(photosdb):
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["incloud"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["incloud"]])
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,12 @@ UUID_DICT = {
|
|||||||
"not_modified": "D05A5FE3-15FB-49A1-A15D-AB3DA6F8B068",
|
"not_modified": "D05A5FE3-15FB-49A1-A15D-AB3DA6F8B068",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def photosdb():
|
def photosdb():
|
||||||
return osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
return osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
|
||||||
|
|
||||||
def test_modified(photosdb):
|
def test_modified(photosdb):
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ UUID_DICT = {
|
|||||||
"not_modified": "35243F7D-88C4-4408-B516-C74406E90C15",
|
"not_modified": "35243F7D-88C4-4408-B516-C74406E90C15",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def photosdb():
|
def photosdb():
|
||||||
return osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
return osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
|||||||
@ -15,6 +15,7 @@ UUID_DICT = {
|
|||||||
def test_path_edited1():
|
def test_path_edited1():
|
||||||
# test a valid edited path
|
# test a valid edited path
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
@ -29,6 +30,7 @@ def test_path_edited1():
|
|||||||
def test_path_edited2():
|
def test_path_edited2():
|
||||||
# test a non-standard (not 00) edited path
|
# test a non-standard (not 00) edited path
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
|||||||
@ -232,6 +232,7 @@ def test_init4():
|
|||||||
# test invalid db
|
# test invalid db
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
(bad_db, bad_db_name) = tempfile.mkstemp(suffix=".db", prefix="osxphotos-")
|
(bad_db, bad_db_name) = tempfile.mkstemp(suffix=".db", prefix="osxphotos-")
|
||||||
@ -608,7 +609,6 @@ def test_keyword_2(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_keyword_not_in_album(photosdb):
|
def test_keyword_not_in_album(photosdb):
|
||||||
|
|
||||||
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
||||||
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
||||||
photos2 = photosdb.photos(keywords=["Kids"])
|
photos2 = photosdb.photos(keywords=["Kids"])
|
||||||
@ -1026,6 +1026,7 @@ def test_date_invalid():
|
|||||||
"""Test date is invalid"""
|
"""Test date is invalid"""
|
||||||
# doesn't run correctly with the module-level fixture
|
# doesn't run correctly with the module-level fixture
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
# UUID_DICT["date_invalid"] has an invalid date that's
|
# UUID_DICT["date_invalid"] has an invalid date that's
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import pytest
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
from osxphotos.photoexporter import PhotoExporter
|
from osxphotos.photoexporter import PhotoExporter
|
||||||
from osxphotos.utils import is_macos, get_macos_version
|
from osxphotos.utils import get_macos_version, is_macos
|
||||||
|
|
||||||
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
OS_VERSION = get_macos_version() if is_macos else (None, None, None)
|
||||||
# SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "17"
|
# SKIP_TEST = "OSXPHOTOS_TEST_EXPORT" not in os.environ or OS_VERSION[1] != "17"
|
||||||
@ -291,13 +291,11 @@ def test_init5(mocker):
|
|||||||
|
|
||||||
|
|
||||||
def test_db_len(photosdb):
|
def test_db_len(photosdb):
|
||||||
|
|
||||||
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
assert len(photosdb) == PHOTOS_DB_LEN
|
assert len(photosdb) == PHOTOS_DB_LEN
|
||||||
|
|
||||||
|
|
||||||
def test_db_version(photosdb):
|
def test_db_version(photosdb):
|
||||||
|
|
||||||
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
# assert photosdb.db_version in osxphotos._TESTED_DB_VERSIONS
|
||||||
assert photosdb.db_version == "6000"
|
assert photosdb.db_version == "6000"
|
||||||
|
|
||||||
@ -307,46 +305,39 @@ def test_photos_version(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_persons(photosdb):
|
def test_persons(photosdb):
|
||||||
|
|
||||||
assert "Katie" in photosdb.persons
|
assert "Katie" in photosdb.persons
|
||||||
assert Counter(PERSONS) == Counter(photosdb.persons)
|
assert Counter(PERSONS) == Counter(photosdb.persons)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords(photosdb):
|
def test_keywords(photosdb):
|
||||||
|
|
||||||
assert "wedding" in photosdb.keywords
|
assert "wedding" in photosdb.keywords
|
||||||
assert Counter(KEYWORDS) == Counter(photosdb.keywords)
|
assert Counter(KEYWORDS) == Counter(photosdb.keywords)
|
||||||
|
|
||||||
|
|
||||||
def test_album_names(photosdb):
|
def test_album_names(photosdb):
|
||||||
|
|
||||||
assert "Pumpkin Farm" in photosdb.albums
|
assert "Pumpkin Farm" in photosdb.albums
|
||||||
assert Counter(ALBUMS) == Counter(photosdb.albums)
|
assert Counter(ALBUMS) == Counter(photosdb.albums)
|
||||||
|
|
||||||
|
|
||||||
def test_keywords_dict(photosdb):
|
def test_keywords_dict(photosdb):
|
||||||
|
|
||||||
keywords = photosdb.keywords_as_dict
|
keywords = photosdb.keywords_as_dict
|
||||||
assert keywords["wedding"] == 3
|
assert keywords["wedding"] == 3
|
||||||
assert keywords == KEYWORDS_DICT
|
assert keywords == KEYWORDS_DICT
|
||||||
|
|
||||||
|
|
||||||
def test_persons_as_dict(photosdb):
|
def test_persons_as_dict(photosdb):
|
||||||
|
|
||||||
persons = photosdb.persons_as_dict
|
persons = photosdb.persons_as_dict
|
||||||
assert persons["Maria"] == 2
|
assert persons["Maria"] == 2
|
||||||
assert persons == PERSONS_DICT
|
assert persons == PERSONS_DICT
|
||||||
|
|
||||||
|
|
||||||
def test_albums_as_dict(photosdb):
|
def test_albums_as_dict(photosdb):
|
||||||
|
|
||||||
albums = photosdb.albums_as_dict
|
albums = photosdb.albums_as_dict
|
||||||
assert albums["Pumpkin Farm"] == 3
|
assert albums["Pumpkin Farm"] == 3
|
||||||
assert albums == ALBUM_DICT
|
assert albums == ALBUM_DICT
|
||||||
|
|
||||||
|
|
||||||
def test_album_sort_order(photosdb):
|
def test_album_sort_order(photosdb):
|
||||||
|
|
||||||
album = [a for a in photosdb.album_info if a.title == "Pumpkin Farm"][0]
|
album = [a for a in photosdb.album_info if a.title == "Pumpkin Farm"][0]
|
||||||
photos = album.photos
|
photos = album.photos
|
||||||
|
|
||||||
@ -355,14 +346,12 @@ def test_album_sort_order(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_album_empty_album(photosdb):
|
def test_album_empty_album(photosdb):
|
||||||
|
|
||||||
album = [a for a in photosdb.album_info if a.title == "EmptyAlbum"][0]
|
album = [a for a in photosdb.album_info if a.title == "EmptyAlbum"][0]
|
||||||
photos = album.photos
|
photos = album.photos
|
||||||
assert photos == []
|
assert photos == []
|
||||||
|
|
||||||
|
|
||||||
def test_attributes(photosdb):
|
def test_attributes(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=["D79B8D77-BFFC-460B-9312-034F2877D35B"])
|
photos = photosdb.photos(uuid=["D79B8D77-BFFC-460B-9312-034F2877D35B"])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -434,7 +423,6 @@ def test_attributes_2(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_missing(photosdb):
|
def test_missing(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -443,7 +431,6 @@ def test_missing(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_favorite(photosdb):
|
def test_favorite(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["favorite"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["favorite"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -451,7 +438,6 @@ def test_favorite(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_not_favorite(photosdb):
|
def test_not_favorite(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["not_favorite"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["not_favorite"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -459,7 +445,6 @@ def test_not_favorite(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_hidden(photosdb):
|
def test_hidden(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["hidden"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["hidden"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -467,7 +452,6 @@ def test_hidden(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_not_hidden(photosdb):
|
def test_not_hidden(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["not_hidden"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["not_hidden"]])
|
||||||
assert len(photos) == 1
|
assert len(photos) == 1
|
||||||
p = photos[0]
|
p = photos[0]
|
||||||
@ -606,7 +590,6 @@ def test_not_ismovie(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_count(photosdb):
|
def test_count(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos()
|
photos = photosdb.photos()
|
||||||
assert len(photos) == PHOTOS_NOT_IN_TRASH_LEN
|
assert len(photos) == PHOTOS_NOT_IN_TRASH_LEN
|
||||||
|
|
||||||
@ -685,13 +668,11 @@ def test_photoinfo_not_intrash(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_keyword_2(photosdb):
|
def test_keyword_2(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(keywords=["wedding"])
|
photos = photosdb.photos(keywords=["wedding"])
|
||||||
assert len(photos) == 2 # won't show the one in the trash
|
assert len(photos) == 2 # won't show the one in the trash
|
||||||
|
|
||||||
|
|
||||||
def test_keyword_not_in_album(photosdb):
|
def test_keyword_not_in_album(photosdb):
|
||||||
|
|
||||||
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
||||||
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
||||||
photos2 = photosdb.photos(keywords=["Kids"])
|
photos2 = photosdb.photos(keywords=["Kids"])
|
||||||
@ -708,20 +689,17 @@ def test_album_folder_name(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_multi_person(photosdb):
|
def test_multi_person(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(persons=["Katie", "Suzy"])
|
photos = photosdb.photos(persons=["Katie", "Suzy"])
|
||||||
|
|
||||||
assert len(photos) == 3
|
assert len(photos) == 3
|
||||||
|
|
||||||
|
|
||||||
def test_get_db_path(photosdb):
|
def test_get_db_path(photosdb):
|
||||||
|
|
||||||
db_path = photosdb.db_path
|
db_path = photosdb.db_path
|
||||||
assert db_path.endswith(PHOTOS_DB_PATH)
|
assert db_path.endswith(PHOTOS_DB_PATH)
|
||||||
|
|
||||||
|
|
||||||
def test_get_library_path(photosdb):
|
def test_get_library_path(photosdb):
|
||||||
|
|
||||||
lib_path = photosdb.library_path
|
lib_path = photosdb.library_path
|
||||||
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
assert lib_path.endswith(PHOTOS_LIBRARY_PATH)
|
||||||
|
|
||||||
@ -1028,14 +1006,12 @@ def test_eq_2():
|
|||||||
|
|
||||||
|
|
||||||
def test_not_eq(photosdb):
|
def test_not_eq(photosdb):
|
||||||
|
|
||||||
photos1 = photosdb.photos(uuid=[UUID_DICT["export"]])
|
photos1 = photosdb.photos(uuid=[UUID_DICT["export"]])
|
||||||
photos2 = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
photos2 = photosdb.photos(uuid=[UUID_DICT["missing"]])
|
||||||
assert photos1[0] != photos2[0]
|
assert photos1[0] != photos2[0]
|
||||||
|
|
||||||
|
|
||||||
def test_photosdb_repr():
|
def test_photosdb_repr():
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
photosdb2 = eval(repr(photosdb))
|
photosdb2 = eval(repr(photosdb))
|
||||||
|
|
||||||
@ -1046,7 +1022,6 @@ def test_photosdb_repr():
|
|||||||
|
|
||||||
|
|
||||||
def test_photosinfo_repr(photosdb):
|
def test_photosinfo_repr(photosdb):
|
||||||
|
|
||||||
photos = photosdb.photos(uuid=[UUID_DICT["favorite"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["favorite"]])
|
||||||
photo = photos[0]
|
photo = photos[0]
|
||||||
photo2 = eval(repr(photo))
|
photo2 = eval(repr(photo))
|
||||||
|
|||||||
@ -33,15 +33,17 @@ def test_db_version():
|
|||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
import osxphotos
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "test" in photosdb.keywords
|
assert "test" in photosdb.keywords
|
||||||
|
|
||||||
|
|
||||||
def test_attributes():
|
def test_attributes():
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
|||||||
@ -36,15 +36,17 @@ def test_db_version():
|
|||||||
|
|
||||||
|
|
||||||
def test_keywords():
|
def test_keywords():
|
||||||
import osxphotos
|
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
assert "test" in photosdb.keywords
|
assert "test" in photosdb.keywords
|
||||||
|
|
||||||
|
|
||||||
def test_attributes():
|
def test_attributes():
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
|
||||||
|
|||||||
@ -5,7 +5,6 @@ from osxphotos.path_utils import sanitize_filename
|
|||||||
|
|
||||||
|
|
||||||
def test_sanitize_filename():
|
def test_sanitize_filename():
|
||||||
|
|
||||||
# basic sanitize
|
# basic sanitize
|
||||||
filenames = {
|
filenames = {
|
||||||
"Foobar.txt": "Foobar.txt",
|
"Foobar.txt": "Foobar.txt",
|
||||||
|
|||||||
@ -7,15 +7,16 @@ import tempfile
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
|
|
||||||
if is_macos:
|
if is_macos:
|
||||||
from osxphotos.photokit import (
|
from osxphotos.photokit import (
|
||||||
|
PHOTOS_VERSION_CURRENT,
|
||||||
|
PHOTOS_VERSION_ORIGINAL,
|
||||||
|
PHOTOS_VERSION_UNADJUSTED,
|
||||||
LivePhotoAsset,
|
LivePhotoAsset,
|
||||||
PhotoAsset,
|
PhotoAsset,
|
||||||
PhotoLibrary,
|
PhotoLibrary,
|
||||||
VideoAsset,
|
VideoAsset,
|
||||||
PHOTOS_VERSION_CURRENT,
|
|
||||||
PHOTOS_VERSION_ORIGINAL,
|
|
||||||
PHOTOS_VERSION_UNADJUSTED,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
pytest.skip(allow_module_level=True)
|
pytest.skip(allow_module_level=True)
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
""" Test PlaceInfo """
|
""" Test PlaceInfo """
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-Places-Catalina-10_15_1.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-Places-Catalina-10_15_1.photoslibrary/database/photos.db"
|
||||||
|
|
||||||
UUID_DICT = {
|
UUID_DICT = {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
""" Test ScoreInfo """
|
""" Test ScoreInfo """
|
||||||
|
|
||||||
from math import isclose
|
from math import isclose
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from osxphotos.scoreinfo import ScoreInfo
|
from osxphotos.scoreinfo import ScoreInfo
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import pytest
|
|||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
||||||
|
|
||||||
LABELS_DICT = {
|
LABELS_DICT = {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import pytest
|
|||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.15.4.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.15.4.photoslibrary/database/photos.db"
|
||||||
PHOTOS_DB_PATH = "/Test-10.15.4.photoslibrary/database/photos.db"
|
PHOTOS_DB_PATH = "/Test-10.15.4.photoslibrary/database/photos.db"
|
||||||
PHOTOS_LIBRARY_PATH = "/Test-10.15.4.photoslibrary"
|
PHOTOS_LIBRARY_PATH = "/Test-10.15.4.photoslibrary"
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import pytest
|
|||||||
|
|
||||||
from osxphotos._constants import _UNKNOWN_PERSON
|
from osxphotos._constants import _UNKNOWN_PERSON
|
||||||
|
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.15.5.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.15.5.photoslibrary/database/photos.db"
|
||||||
PHOTOS_DB_PATH = "/Test-10.15.5.photoslibrary/database/photos.db"
|
PHOTOS_DB_PATH = "/Test-10.15.5.photoslibrary/database/photos.db"
|
||||||
PHOTOS_LIBRARY_PATH = "/Test-10.15.5.photoslibrary"
|
PHOTOS_LIBRARY_PATH = "/Test-10.15.5.photoslibrary"
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
PHOTOS_DB = "./tests/Test-10.14.6.photoslibrary/database/photos.db"
|
||||||
PHOTOS_DB_PATH = "/Test-10.14.6.photoslibrary/database/photos.db"
|
PHOTOS_DB_PATH = "/Test-10.14.6.photoslibrary/database/photos.db"
|
||||||
PHOTOS_LIBRARY_PATH = "/Test-10.14.6.photoslibrary"
|
PHOTOS_LIBRARY_PATH = "/Test-10.14.6.photoslibrary"
|
||||||
@ -18,6 +17,7 @@ PHOTOS_DB_LEN = 13
|
|||||||
PHOTOS_NOT_IN_TRASH_LEN = 12
|
PHOTOS_NOT_IN_TRASH_LEN = 12
|
||||||
PHOTOS_IN_TRASH_LEN = 1
|
PHOTOS_IN_TRASH_LEN = 1
|
||||||
|
|
||||||
|
|
||||||
def test_album_names():
|
def test_album_names():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ def test_portrait1():
|
|||||||
photos = photosdb.photos(uuid=[UUID_DICT["no_specials"]])
|
photos = photosdb.photos(uuid=[UUID_DICT["no_specials"]])
|
||||||
assert not photos[0].portrait
|
assert not photos[0].portrait
|
||||||
|
|
||||||
|
|
||||||
def test_portrait2():
|
def test_portrait2():
|
||||||
import osxphotos
|
import osxphotos
|
||||||
|
|
||||||
|
|||||||
@ -1,21 +1,19 @@
|
|||||||
"""Tests for sqlite_utils """
|
"""Tests for sqlite_utils """
|
||||||
|
|
||||||
import pytest
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
from osxphotos.sqlite_utils import sqlite_open_ro, sqlite_db_is_locked
|
import pytest
|
||||||
|
|
||||||
|
from osxphotos.sqlite_utils import sqlite_db_is_locked, sqlite_open_ro
|
||||||
|
|
||||||
DB_UNLOCKED_10_15 = "./tests/Test-10.15.1.photoslibrary/database/photos.db"
|
DB_UNLOCKED_10_15 = "./tests/Test-10.15.1.photoslibrary/database/photos.db"
|
||||||
|
|
||||||
|
|
||||||
def test_db_is_locked_unlocked():
|
def test_db_is_locked_unlocked():
|
||||||
|
|
||||||
assert not sqlite_db_is_locked(DB_UNLOCKED_10_15)
|
assert not sqlite_db_is_locked(DB_UNLOCKED_10_15)
|
||||||
|
|
||||||
|
|
||||||
def test_open_sqlite_ro():
|
def test_open_sqlite_ro():
|
||||||
|
|
||||||
conn, cur = sqlite_open_ro(DB_UNLOCKED_10_15)
|
conn, cur = sqlite_open_ro(DB_UNLOCKED_10_15)
|
||||||
assert isinstance(conn, sqlite3.Connection)
|
assert isinstance(conn, sqlite3.Connection)
|
||||||
assert isinstance(cur, sqlite3.Cursor)
|
assert isinstance(cur, sqlite3.Cursor)
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import pytest
|
|||||||
import osxphotos
|
import osxphotos
|
||||||
from osxphotos.exiftool import get_exiftool_path
|
from osxphotos.exiftool import get_exiftool_path
|
||||||
from osxphotos.export_db import ExportDBInMemory
|
from osxphotos.export_db import ExportDBInMemory
|
||||||
|
from osxphotos.photoinfo import PhotoInfoNone
|
||||||
from osxphotos.phototemplate import (
|
from osxphotos.phototemplate import (
|
||||||
PUNCTUATION,
|
PUNCTUATION,
|
||||||
TEMPLATE_SUBSTITUTIONS,
|
TEMPLATE_SUBSTITUTIONS,
|
||||||
@ -14,10 +15,10 @@ from osxphotos.phototemplate import (
|
|||||||
PhotoTemplate,
|
PhotoTemplate,
|
||||||
RenderOptions,
|
RenderOptions,
|
||||||
)
|
)
|
||||||
from osxphotos.photoinfo import PhotoInfoNone
|
|
||||||
from osxphotos.utils import is_macos
|
from osxphotos.utils import is_macos
|
||||||
from .photoinfo_mock import PhotoInfoMock
|
|
||||||
from .locale_util import setlocale
|
from .locale_util import setlocale
|
||||||
|
from .photoinfo_mock import PhotoInfoMock
|
||||||
|
|
||||||
try:
|
try:
|
||||||
exiftool = get_exiftool_path()
|
exiftool = get_exiftool_path()
|
||||||
|
|||||||
@ -608,7 +608,6 @@ def test_keyword_2(photosdb):
|
|||||||
|
|
||||||
|
|
||||||
def test_keyword_not_in_album(photosdb):
|
def test_keyword_not_in_album(photosdb):
|
||||||
|
|
||||||
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
# find all photos with keyword "Kids" not in the album "Pumpkin Farm"
|
||||||
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
photos1 = photosdb.photos(albums=["Pumpkin Farm"])
|
||||||
photos2 = photosdb.photos(keywords=["Kids"])
|
photos2 = photosdb.photos(keywords=["Kids"])
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import sys
|
|||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
url = "https://www.exiftool.org/"
|
url = "https://www.exiftool.org/"
|
||||||
json_file = "exiftool_filetypes.json"
|
json_file = "exiftool_filetypes.json"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user