soulsync/tests/wishlist
Broque Thomas 99a763dace fix: drop redundant library-cleanup pass from wishlist download flows
Both the auto and manual wishlist download paths called
`remove_tracks_already_in_library` before submitting the batch — a
serial DB lookup per track per artist (~1s/track on a 24-track
wishlist). The batches set `force_download_all=True` which is
explicitly documented as "skip the expensive library check" — the
pre-flight cleanup was contradicting that flag.

Removed the cleanup call from both flows. Kept `remove_wishlist_duplicates`
(fast SQL DELETE) and the standalone `/api/wishlist/cleanup` endpoint
that exposes the library scan as explicit user-triggered maintenance.

Safety check on the trade-off:
- post-processing at `core/imports/pipeline.py:576-624` already handles
  re-downloads defensively: existing file with metadata → skip overwrite
  + delete source duplicate, no library corruption.
- Master worker's analysis loop normally removes wishlist entries for
  found tracks via `_check_and_remove_track_from_wishlist_by_metadata`,
  so stale wishlist entries should be rare in practice.
- Worst case for the rare orphan: one redundant download attempt that
  the post-processing layer no-ops on. Bandwidth waste, not data damage.

Tests updated:
- `..._does_not_run_library_cleanup` (renamed from `_skips_enhance_tracks_during_cleanup`)
  asserts no DB track-existence checks happen and no wishlist removals
  fire — both `enhance` and "owned" tracks reach the master worker.
- `..._marks_batch_complete_when_wishlist_genuinely_empty` (renamed from
  `..._after_cleanup`) covers the path where the wishlist starts empty.

Full suite: 1232 passing. Ruff clean.
2026-04-28 20:30:12 -07:00
..
__init__.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_automation.py Trim wishlist runtime plumbing 2026-04-28 21:52:21 +03:00
test_cancelled_payload.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_classification.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_cleanup.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_failed_track_payload.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_manual_download.py fix: drop redundant library-cleanup pass from wishlist download flows 2026-04-28 20:30:12 -07:00
test_payloads.py Expand wishlist test coverage 2026-04-28 21:17:47 +03:00
test_presence.py Expand wishlist test coverage 2026-04-28 21:17:47 +03:00
test_processing.py Expand wishlist test coverage 2026-04-28 21:17:47 +03:00
test_reporting.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_resolution.py Expand wishlist test coverage 2026-04-28 21:17:47 +03:00
test_routes.py Trim wishlist runtime plumbing 2026-04-28 21:52:21 +03:00
test_selection.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
test_service.py Expand wishlist test coverage 2026-04-28 21:17:47 +03:00
test_state.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00