Skip to content

Add SharedPhotosService and fix review feedback from PR #122 - #136

Closed
mandarons with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-code-comments
Closed

Add SharedPhotosService and fix review feedback from PR #122#136
mandarons with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-code-comments

Conversation

Copilot AI commented May 28, 2026

Copy link
Copy Markdown
Contributor

Implements SharedPhotosService (a new PhotoLibrary subclass for shared iCloud photo libraries) and addresses all code review comments from PR #122, plus fixes the resulting ruff lint failures in CI.

New: SharedPhotosService (icloudpy/services/photos.py)

  • Distinct class from PhotosService, targeting the /production/shared endpoint
  • __init__ initializes zones = [] before the try block; raises ICloudPyServiceNotActivatedException on fetch failure or empty zones (instead of silently returning with an uninitialised PhotoLibrary)
  • libraries property lazily fetches and caches self._libraries, with zones = [] guard before the try block
  • Removed duplicate self._libraries = None assignment and commented-out URL

icloudpy/base.py

  • Initialized self._shared_photos = None alongside self._photos in __init__
  • Added shared_photos property with correct lazy-init guard (if not self._shared_photos)

Tests (tests/test_photos.py, tests/__init__.py)

  • Added SharedPhotosServiceInitializationTests covering initialization params, zone ID, endpoint structure, libraries caching, and exception handling
  • Extended ICloudPySessionMock.request() to return distinct zone fixtures for /production/shared/zones/list vs. /production/private/zones/list

Lint fixes

  • Added missing trailing commas (COM812) on multi-line calls in SharedPhotosService
  • Moved SharedPhotosService and MagicMock imports to top-level in test file (I001)

- Fix docstring to say "Shared Photos" instead of generic "Photos"
- Remove duplicate `self._libraries = None` assignment
- Remove commented-out code
- Initialize `zones = []` before try block to prevent NameError
- Raise ICloudPyServiceNotActivatedException on zone fetch failure or empty zones
- Add `self._libraries = libraries` caching in libraries property
- Add explicit `return self._libraries` in libraries property
- Initialize `self._shared_photos = None` in base.py __init__
- Fix condition to check `self._shared_photos` instead of `self._photos`
- Add tests for SharedPhotosService
Copilot AI changed the title [WIP] Fix code based on review comments Add SharedPhotosService with review fixes applied May 28, 2026
Copilot AI requested a review from mandarons May 28, 2026 16:09
- Add trailing commas to ICloudPyServiceNotActivatedException raises in SharedPhotosService (COM812)
- Add trailing comma to PhotoLibrary constructor call in libraries property (COM812)
- Move SharedPhotosService and MagicMock imports to top of test file (I001)
Copilot AI changed the title Add SharedPhotosService with review fixes applied Add SharedPhotosService and fix review feedback from PR #122 May 28, 2026
@mandarons mandarons closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants