Bug search info macos13 816 (#831)

* Fixed SearchInfo for macOS 13, #816

* Additional fixes for SearchInfo, #816
This commit is contained in:
Rhet Turnbull
2022-11-13 21:17:43 -08:00
committed by GitHub
parent de14583215
commit c2c2da6c95
5 changed files with 96 additions and 6 deletions

View File

@@ -30,6 +30,8 @@ A couple of tests require interaction with Photos and configuring a specific tes
## Test Photo Libraries
**Important**: The test code uses several test photo libraries created on various version of MacOS. If you need to inspect one of these or modify one for a test, make a copy of the library (for example, copy it to your ~/Pictures folder) then open the copy in Photos. Once done, copy the revised library back to the tests/ folder. If you do not do this, the Photos background process photoanalysisd will forever try to process the library resulting in updates to the database which will cause git to see changes to the file you didn't intend. I'm not aware of any way to disassociate photoanalysisd from the library once you've opened it in Photos.
Some of the "search_info" tests require data from my personal library on Catalina 10.15.7. The data is generated by running `tests/generate_search_info_test_data.py`
## Attribution ##
These tests utilize a test Photos library. The test library is populated with photos from [flickr](https://www.flickr.com) and from my own photo library. All images used are licensed under Creative Commons 2.0 Attribution [license](https://creativecommons.org/licenses/by/2.0/).

File diff suppressed because one or more lines are too long

View File

@@ -198,6 +198,42 @@ UUID_MOMENT = {
UUID_LABELS = {"6191423D-8DB8-4D4C-92BE-9BBBA308AAC4": ["Plant", "Flower Arrangement"]}
UUID_CAMERA = {
"4D521201-92AC-43E5-8F7C-59BC41C37A96": "Canon PowerShot G10",
"A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C": "",
}
UUID_DETECTED_TEXT = {
"4D521201-92AC-43E5-8F7C-59BC41C37A96": ["mint", "mojito", "sprouts"],
"A1DD1F98-2ECD-431F-9AC9-5AFEFE2D3A5C": [],
}
UUID_SEARCH_INFO = {
"3DD2C897-F19E-4CA6-8C22-B027D5A71907": {
"labels": ["Art", "Clothing", "Plant", "Statue"],
"place_names": ["River Torrens/Karrawirra Parri"],
"streets": ["River Torrens Linear Park Trl"],
"neighborhoods": ["Central Ward"],
"city": "",
"locality_names": ["Adelaide", "South Australia"],
"state": "Adelaide",
"state_abbreviation": "SA",
"country": "Australia",
"bodies_of_water": [],
"month": "June",
"year": "2017",
"holidays": [],
"activities": [],
"season": "Summer",
"venues": [],
"venue_types": [],
"media_types": [],
"detected_text": [],
"camera": "Apple iPhone 6s",
}
}
@pytest.fixture(scope="module")
def photosdb():
@@ -1173,3 +1209,27 @@ def test_labels(photosdb):
photo = photosdb.get_photo(uuid=uuid)
for label in labels:
assert label in photo.labels
def test_search_info_camera(photosdb):
"""Test SearchInfo camera (new to Photos 8)"""
for uuid, camera in UUID_CAMERA.items():
photo = photosdb.get_photo(uuid=uuid)
assert photo.search_info.camera == camera
def test_search_info_detected_text(photosdb):
"""Test SearchInfo detected text (new to Photos 8)"""
for uuid, detected_text in UUID_DETECTED_TEXT.items():
photo = photosdb.get_photo(uuid=uuid)
assert (
sorted([x.lower() for x in photo.search_info.detected_text])
== detected_text
)
def test_search_info_dict(photosdb):
"""Test SearchInfo changes for Photos 8"""
for uuid, search_info in UUID_SEARCH_INFO.items():
photo = photosdb.get_photo(uuid=uuid)
assert photo.search_info.asdict() == search_info