Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyicloud/services/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ def __init__(
@property
def id(self) -> str:
"""Gets the photo id."""
return self._master_record["recordName"]
return self._asset_record["recordName"]
Comment on lines 1590 to +1593
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id docstring is now ambiguous: this property returns the asset recordName (used by album relation operations), not the master recordName. Please update the docstring (and ideally mention/expose the master record identifier separately) so API consumers can distinguish the two identifiers.

Copilot uses AI. Check for mistakes.
Comment on lines 1590 to +1593
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is intended to fix PhotoAlbum.add_photo() by switching PhotoAsset.id to the asset recordName, but there is currently no direct unit test asserting the add_photo() request payload uses the asset id in both itemId and recordName. Adding a focused test would prevent regressions and ensure the original issue (#207) stays fixed.

Copilot uses AI. Check for mistakes.

@property
def filename(self) -> str:
Expand Down
31 changes: 21 additions & 10 deletions tests/services/test_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ def test_base_photo_album_get_photos_at(mock_photo_library: MagicMock) -> None:
"records": [
{
"recordType": "CPLAsset",
"recordName": "asset1",
"fields": {"masterRef": {"value": {"recordName": "master1"}}},
},
{
Expand All @@ -632,6 +633,7 @@ def test_base_photo_album_get_photos_at(mock_photo_library: MagicMock) -> None:
)
photos = list(album.photos)
assert len(photos) == 1
assert photos[0].id == "asset1"
mock_photo_library.service.session.post.assert_called()


Expand All @@ -649,6 +651,7 @@ def test_base_photo_album_iter(mock_photo_library: MagicMock) -> None:
"records": [
{
"recordType": "CPLAsset",
"recordName": "asset1",
"fields": {"masterRef": {"value": {"recordName": "master1"}}},
},
{
Expand All @@ -673,6 +676,7 @@ def test_base_photo_album_iter(mock_photo_library: MagicMock) -> None:
)
photos = list(iter(album))
assert len(photos) == 1
assert photos[0].id == "asset1"
mock_photo_library.service.session.post.assert_called()


Expand Down Expand Up @@ -2452,11 +2456,12 @@ def test_photo_album_get_photo_success(mock_photo_library: MagicMock) -> None:
"records": [
{
"recordType": "CPLAsset",
"fields": {"masterRef": {"value": {"recordName": "target_photo"}}},
"recordName": "target_photo",
"fields": {"masterRef": {"value": {"recordName": "master1"}}},
},
{
"recordType": "CPLMaster",
"recordName": "target_photo",
"recordName": "master1",
},
]
}
Expand Down Expand Up @@ -2490,11 +2495,12 @@ def test_photo_album_get_photo_not_found(mock_photo_library: MagicMock) -> None:
"records": [
{
"recordType": "CPLAsset",
"fields": {"masterRef": {"value": {"recordName": "different_photo"}}},
"recordName": "different_photo",
"fields": {"masterRef": {"value": {"recordName": "master1"}}},
},
{
"recordType": "CPLMaster",
"recordName": "different_photo",
"recordName": "master1",
},
]
}
Expand Down Expand Up @@ -2553,27 +2559,32 @@ def test_photo_album_get_photo_multiple_photos_found_correct_one(
"records": [
{
"recordType": "CPLAsset",
"fields": {"masterRef": {"value": {"recordName": "photo1"}}},
"recordName": "photo1",
"fields": {"masterRef": {"value": {"recordName": "master_photo1"}}},
},
{
"recordType": "CPLMaster",
"recordName": "photo1",
"recordName": "master_photo1",
},
{
"recordType": "CPLAsset",
"fields": {"masterRef": {"value": {"recordName": "target_photo"}}},
"recordName": "target_photo",
"fields": {
"masterRef": {"value": {"recordName": "master_target_photo"}}
},
},
{
"recordType": "CPLMaster",
"recordName": "target_photo",
"recordName": "master_target_photo",
},
{
"recordType": "CPLAsset",
"fields": {"masterRef": {"value": {"recordName": "photo3"}}},
"recordName": "photo3",
"fields": {"masterRef": {"value": {"recordName": "master_photo3"}}},
},
{
"recordType": "CPLMaster",
"recordName": "photo3",
"recordName": "master_photo3",
},
]
}
Expand Down
Loading