@@ -19,6 +19,7 @@ from photoscript import Photo
|
||||
from pytest import MonkeyPatch, approx
|
||||
|
||||
from osxphotos import PhotosDB, QueryOptions
|
||||
from osxphotos._constants import UUID_PATTERN
|
||||
from osxphotos.cli.import_cli import import_cli
|
||||
from osxphotos.datetime_utils import datetime_remove_tz
|
||||
from osxphotos.exiftool import get_exiftool_path
|
||||
@@ -101,9 +102,7 @@ def parse_import_output(output: str) -> Dict[str, str]:
|
||||
|
||||
results = {}
|
||||
for line in output.split("\n"):
|
||||
pattern = re.compile(
|
||||
r"Imported ([\w\.]+)\s.*UUID\s([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})"
|
||||
)
|
||||
pattern = re.compile(r"Imported ([\w\.]+)\s.*UUID\s(" + UUID_PATTERN + r")")
|
||||
if match := re.match(pattern, line):
|
||||
file = match[1]
|
||||
uuid = match[2]
|
||||
|
||||
41
tests/test_photosdb_utils.py
Normal file
41
tests/test_photosdb_utils.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Test photosdb_utils """
|
||||
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
from osxphotos.photosdb.photosdb_utils import (
|
||||
get_db_path_for_library,
|
||||
get_photos_library_version,
|
||||
)
|
||||
|
||||
LIBRARIES = {
|
||||
2: pathlib.Path("tests/Test-10.12.6.photoslibrary"),
|
||||
3: pathlib.Path("tests/Test-10.13.6.photoslibrary"),
|
||||
4: pathlib.Path("tests/Test-10.14.6.photoslibrary"),
|
||||
5: pathlib.Path("tests/Test-10.15.7.photoslibrary"),
|
||||
6: pathlib.Path("tests/Test-10.16.0.photoslibrary"),
|
||||
7: pathlib.Path("tests/Test-12.0.1.photoslibrary"),
|
||||
8: pathlib.Path("tests/Test-13.0.0.photoslibrary"),
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version,library_path", list(LIBRARIES.items()))
|
||||
def test_get_photos_library_version_library_path(version, library_path):
|
||||
"""Test get_photos_library_version with library path"""
|
||||
photos_version = get_photos_library_version(library_path)
|
||||
assert photos_version == version
|
||||
|
||||
|
||||
@pytest.mark.parametrize("version,library_path", list(LIBRARIES.items()))
|
||||
def test_get_photos_library_version_db_path(version, library_path):
|
||||
"""Test get_photos_library_version with database path"""
|
||||
photos_version = get_photos_library_version(library_path / "database" / "photos.db")
|
||||
assert photos_version == version
|
||||
|
||||
|
||||
@pytest.mark.parametrize("library_path", list(LIBRARIES.values()))
|
||||
def test_get_db_path_for_library(library_path):
|
||||
"""Test get_db_path_for_library"""
|
||||
db_path = get_db_path_for_library(library_path)
|
||||
assert db_path.is_file()
|
||||
Reference in New Issue
Block a user