Added moment_info, #71

This commit is contained in:
Rhet Turnbull
2022-05-03 22:12:09 -07:00
parent e9bbfeca52
commit 9bc5890589
35 changed files with 2490 additions and 1673 deletions

View File

@@ -175,6 +175,19 @@ PATH_HEIC_EDITED = (
UUID_IS_REFERENCE = "A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C"
UUID_NOT_REFERENCE = "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51"
UUID_MOMENT = {
"3DD2C897-F19E-4CA6-8C22-B027D5A71907": {
"uuid": "3DD2C897-F19E-4CA6-8C22-B027D5A71907",
"location": (-34.91889167000001, 138.59686167),
"title": "Adelaide",
"subtitle": "",
"start_date": "2017-06-20T17:18:56.518000+09:30",
"end_date": "2017-06-20T17:18:56.518000+09:30",
"date": "2017-06-20T17:18:56.518000+09:30",
"modification_date": "2020-04-06T15:22:24.595584+09:30",
}
}
@pytest.fixture(scope="module")
def photosdb():
@@ -1125,3 +1138,17 @@ def test_no_adjustments(photosdb):
photo = photosdb.get_photo(UUID_DICT["no_adjustments"])
assert photo.adjustments is None
@pytest.mark.parametrize("info", UUID_MOMENT.values())
def test_moment(photosdb, info):
"""test PhotoInfo.moment"""
photo = photosdb.get_photo(uuid=info["uuid"])
assert photo.moment_info.title == info["title"]
assert photo.moment_info.asdict()["title"] == info["title"]
assert photo.moment_info.subtitle == info["subtitle"]
assert photo.moment_info.location == info["location"]
assert photo.moment_info.start_date.isoformat() == info["start_date"]
assert photo.moment_info.end_date.isoformat() == info["end_date"]
assert photo.moment_info.date.isoformat() == info["date"]
assert photo.moment_info.modification_date.isoformat() == info["modification_date"]

View File

@@ -259,6 +259,19 @@ UUID_DETECTED_TEXT = {
"A92D9C26-3A50-4197-9388-CB5F7DB9FA91": None,
}
UUID_MOMENT = {
"7FD37B5F-6FAA-4DB1-8A29-BF9C37E38091": {
"uuid": "7FD37B5F-6FAA-4DB1-8A29-BF9C37E38091",
"location": (20.687278329999998, -156.44366333),
"title": "Hawaiian Islands",
"subtitle": "",
"start_date": "2019-09-15T18:37:17.287000-10:00",
"end_date": "2019-09-15T18:37:17.287000-10:00",
"date": "2019-09-15T18:37:17.287000-10:00",
"modification_date": "2022-02-04T03:51:25.161460-10:00",
}
}
@pytest.fixture(scope="module")
def photosdb():
@@ -1459,3 +1472,17 @@ def test_detected_text(photosdb):
assert expected_text in detected_text
else:
assert not detected_text
@pytest.mark.parametrize("info", UUID_MOMENT.values())
def test_moment(photosdb, info):
"""test PhotoInfo.moment"""
photo = photosdb.get_photo(uuid=info["uuid"])
assert photo.moment_info.title == info["title"]
assert photo.moment_info.asdict()["title"] == info["title"]
assert photo.moment_info.subtitle == info["subtitle"]
assert photo.moment_info.location == info["location"]
assert photo.moment_info.start_date.isoformat() == info["start_date"]
assert photo.moment_info.end_date.isoformat() == info["end_date"]
assert photo.moment_info.date.isoformat() == info["date"]
assert photo.moment_info.modification_date.isoformat() == info["modification_date"]

View File

@@ -90,31 +90,6 @@ UUID_DOWNLOAD_MISSING = "C6C712C5-9316-408D-A3C3-125661422DA9" # IMG_8844.JPG
UUID_FILE = "tests/uuid_from_file.txt"
SKIP_UUID_FILE = "tests/skip_uuid_from_file.txt"
CLI_OUTPUT_NO_SUBCOMMAND = [
"Options:",
"--db <Photos database path> Specify Photos database path. Path to Photos",
"library/database can be specified using either",
"--db or directly as PHOTOS_LIBRARY positional",
"argument.",
"--json Print output in JSON format.",
"-v, --version Show the version and exit.",
"-h, --help Show this message and exit.",
"Commands:",
" albums Print out albums found in the Photos library.",
" dump Print list of all photos & associated info from the Photos",
" export Export photos from the Photos database.",
" help Print help; for help on commands: help <command>.",
" info Print out descriptive info of the Photos library database.",
" install Install Python packages into the same environment as osxphotos",
" keywords Print out keywords found in the Photos library",
" labels Print out image classification labels found in the Photos",
" list Print list of Photos libraries found on the system.",
" persons Print out persons (faces) found in the Photos library.",
" places Print out places found in the Photos library.",
" query Query the Photos database using 1 or more search options; if",
" uninstall Uninstall Python packages from the osxphotos environment",
]
CLI_OUTPUT_QUERY_UUID = '[{"uuid": "D79B8D77-BFFC-460B-9312-034F2877D35B", "filename": "D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "original_filename": "Pumkins2.jpg", "date": "2018-09-28T16:07:07-04:00", "description": "Girl holding pumpkin", "title": "I found one!", "keywords": ["Kids"], "albums": ["Pumpkin Farm", "Test Album", "Multi Keyword"], "persons": ["Katie"], "path": "/tests/Test-10.15.7.photoslibrary/originals/D/D79B8D77-BFFC-460B-9312-034F2877D35B.jpeg", "ismissing": false, "hasadjustments": false, "external_edit": false, "favorite": false, "hidden": false, "latitude": 41.256566, "longitude": -95.940257, "path_edited": null, "shared": false, "isphoto": true, "ismovie": false, "uti": "public.jpeg", "burst": false, "live_photo": false, "path_live_photo": null, "iscloudasset": false, "incloud": null}]'
CLI_EXPORT_FILENAMES = [
@@ -1066,11 +1041,9 @@ def test_osxphotos():
runner = CliRunner()
result = runner.invoke(cli_main, [])
output = result.output
assert result.exit_code == 0
for line in CLI_OUTPUT_NO_SUBCOMMAND:
assert line.strip() in output
assert "Print information about osxphotos" in result.output
def test_osxphotos_help_1():
@@ -1078,10 +1051,8 @@ def test_osxphotos_help_1():
runner = CliRunner()
result = runner.invoke(cli_main, ["help"])
output = result.output
assert result.exit_code == 0
for line in CLI_OUTPUT_NO_SUBCOMMAND:
assert line.strip() in output
assert "Print information about osxphotos" in result.output
def test_osxphotos_help_2():

View File

@@ -180,6 +180,19 @@ PATH_HEIC_EDITED = (
UUID_IS_REFERENCE = "A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C"
UUID_NOT_REFERENCE = "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51"
UUID_MOMENT = {
"3DD2C897-F19E-4CA6-8C22-B027D5A71907": {
"uuid": "3DD2C897-F19E-4CA6-8C22-B027D5A71907",
"location": (-34.91889167000001, 138.59686167),
"title": "Adelaide",
"subtitle": "",
"start_date": "2017-06-20T17:18:56.518000+09:30",
"end_date": "2017-06-20T17:18:56.518000+09:30",
"date": "2017-06-20T17:18:56.518000+09:30",
"modification_date": "2020-04-06T15:22:24.595584+09:30",
}
}
@pytest.fixture(scope="module")
def photosdb():
@@ -1130,3 +1143,17 @@ def test_no_adjustments(photosdb):
photo = photosdb.get_photo(UUID_DICT["no_adjustments"])
assert photo.adjustments is None
@pytest.mark.parametrize("info", UUID_MOMENT.values())
def test_moment(photosdb, info):
"""test PhotoInfo.moment"""
photo = photosdb.get_photo(uuid=info["uuid"])
assert photo.moment_info.title == info["title"]
assert photo.moment_info.asdict()["title"] == info["title"]
assert photo.moment_info.subtitle == info["subtitle"]
assert photo.moment_info.location == info["location"]
assert photo.moment_info.start_date.isoformat() == info["start_date"]
assert photo.moment_info.end_date.isoformat() == info["end_date"]
assert photo.moment_info.date.isoformat() == info["date"]
assert photo.moment_info.modification_date.isoformat() == info["modification_date"]

View File

@@ -333,7 +333,9 @@ UUID_CONDITIONAL = {
"{photo.score.overall >= 0.7?YES,NO}": ["NO"],
"{photo.score.overall not < 0.7?YES,NO}": ["NO"],
"{folder_album(-) contains Folder1-SubFolder2-AlbumInFolder?YES,NO}": ["YES"],
"{folder_album( - ) contains Folder1 - SubFolder2 - AlbumInFolder?YES,NO}": ["YES"],
"{folder_album( - ) contains Folder1 - SubFolder2 - AlbumInFolder?YES,NO}": [
"YES"
],
"{folder_album(-)[In,] contains Folder1-SubFolder2-AlbumFolder?YES,NO}": [
"YES"
],
@@ -395,6 +397,14 @@ UUID_ALBUM_SEQ = {
},
}
UUID_MOMENT = {
"7FD37B5F-6FAA-4DB1-8A29-BF9C37E38091": {
"templates": {
"{moment}": ["Hawaiian Islands"],
}
}
}
UUID_EMPTY_TITLE = "7783E8E6-9CAC-40F3-BE22-81FB7051C266" # IMG_3092.heic
UUID_EMPTY_TITLE_HAS_DESCRIPTION = "E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51" # wedding.jpg
@@ -1243,3 +1253,12 @@ def test_no_project(photosdb_project):
for template, value in TEMPLATE_VALUES_NO_PROJECT.items():
rendered, _ = photo.render_template(template)
assert rendered == value
def test_moment(photosdb):
"""Test {moment} template"""
for uuid in UUID_MOMENT:
photo = photosdb.get_photo(uuid)
for template, value in UUID_MOMENT[uuid]["templates"].items():
rendered, _ = photo.render_template(template)
assert rendered == value