soulsync/tests/imports
BoulderBadgeDad b95a8f539e Auto-download: resolve an album track's real position from its album (not 1/1)
Tracks auto-downloaded from the playlist pipeline / wishlist / watchlist landed as
01/1 even though they belong to multi-track albums (wolf/Sokhi; verified live —
Deezer says 'Obelisk' is track 9 of The Grand Mirage, Olives is 3/4, etc.).

Root cause, located in code: discovery doesn't carry a per-track position for
sources whose search/track endpoint omits it (Deezer search, MusicBrainz
recordings — only their ALBUM endpoint has it). detect_album_info_web then set
'track_number': track_info.get('track_number') (= None) and never looked it up
from the album it HAD identified (context.py); the pipeline floored it to 1. The
one helper that does an album lookup only ran for the no-album-context branch and
is gated off by default. Not isolated to Deezer — the gap is source-agnostic.

Fix: when the album is known (album_id present) but the position is missing,
resolve the REAL (track_number, disc_number) from the album's own track list via
the source-agnostic get_album_tracks_for_source — using the album id discovery
already picked (no re-search, no edition guessing). Matches by ISRC -> source
track id -> title. Fail-safe: any miss/error leaves the number untouched, so it
still falls through to the filename exactly as before — never worse than today.

kettui: pure seam core/imports/album_position.resolve_track_position_in_album
(I/O-free, ISRC>id>title priority, skips position-less entries) + a fail-safe
integration wrapper, both covered — 11 tests incl. the 'Obelisk = 9/12' case,
priority resolution, and never-raises-on-fetch-error. 788 import/context/pipeline
tests green, ruff clean.
2026-06-22 13:32:24 -07:00
..
test_album_grouping.py Library: group imported albums by canonical release id, not just the name string 2026-06-18 09:16:00 -07:00
test_album_matching_exact_id.py Auto-import matching: fix Deezer source classification + bump tolerance 2026-05-09 15:53:17 -07:00
test_album_matching_helper.py Auto-import polish: real-file tag reader test, source-aware duration, pin consolation 2026-05-09 11:08:09 -07:00
test_album_position.py Auto-download: resolve an album track's real position from its album (not 1/1) 2026-06-22 13:32:24 -07:00
test_album_search_scoring.py Auto-import: fall through to other metadata sources when primary returns no match 2026-05-12 12:32:18 -07:00
test_auto_import_clear_completed_endpoint.py Import history: Clear History button now sweeps stuck 'processing' rows 2026-05-12 12:53:37 -07:00
test_auto_import_context_shape.py Auto-import: fall through to other metadata sources when primary returns no match 2026-05-12 12:32:18 -07:00
test_auto_import_executor.py Auto-import: bounded ThreadPoolExecutor + per-candidate UI state isolation 2026-05-09 17:45:42 -07:00
test_auto_import_live_progress.py Auto-import: live per-track progress + in-progress history row 2026-05-02 22:34:09 -07:00
test_auto_import_multi_disc_matching.py Auto-import: respect disc_number in dedup + match scoring 2026-05-08 22:36:51 -07:00
test_auto_import_multi_source_fallback.py Auto-import: fall through to other metadata sources when primary returns no match 2026-05-12 12:32:18 -07:00
test_auto_import_scanner_grouping.py Auto-import: dedup on folder_hash, not path — fixes silent-skip bug 2026-05-09 14:09:19 -07:00
test_auto_import_tag_reader_real_files.py Auto-import polish: real-file tag reader test, source-aware duration, pin consolation 2026-05-09 11:08:09 -07:00
test_build_single_import_context_typed_path.py Migrate album-info builders to typed Album path 2026-05-03 22:53:12 -07:00
test_dedup_orphan_cleanup.py Prune slskd dedup orphans after import 2026-05-01 09:35:08 -07:00
test_duration_tolerance_resolution.py Configurable duration tolerance for downloaded-file integrity check 2026-05-14 06:53:36 -07:00
test_expected_duration_for_check.py Import: don't duration-quarantine manual imports against a re-resolved release (#804) 2026-06-07 23:02:34 -07:00
test_file_integrity.py Integrity check: don't quarantine valid streamed FLAC as 'zero-length' (#756) 2026-05-31 11:28:40 -07:00
test_folder_artist_override.py Fix import artist override and verification review 2026-06-11 01:28:31 +02:00
test_import_album.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
test_import_context.py Multi-artist tags: Search → Download Now finally knows its metadata source (Netti93) 2026-06-09 17:20:16 -07:00
test_import_file_ops.py Fix album-bundle downloads landing every track as track 1 2026-05-26 21:04:27 -07:00
test_import_filename.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
test_import_guards.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
test_import_paths.py Fix #767: Library Organizer dry run no longer creates folders 2026-06-02 10:32:06 -07:00
test_import_pipeline.py PR #801 follow-up: default-config template contradicted the retry engine's documented default 2026-06-07 11:04:28 -07:00
test_import_rejection_reason.py Fix #764: manual import reported quarantined files as a successful "Done" 2026-06-02 08:40:26 -07:00
test_import_resolution_single_track_context.py Move metadata helpers into package modules 2026-04-29 11:28:42 +03:00
test_import_routes.py Import: don't duration-quarantine manual imports against a re-resolved release (#804) 2026-06-07 23:02:34 -07:00
test_import_side_effects.py Add torrent and usenet release staging support 2026-05-21 14:22:21 -07:00
test_import_singles_route_through_album_path.py Route imported singles/EPs through album_path template 2026-04-30 21:33:09 -07:00
test_import_staging.py Show MusicBrainz release variants in import 2026-05-24 09:33:19 -07:00
test_lossy_copy_delete_original.py Honor lossy_copy.delete_original after successful conversion 2026-05-02 14:26:46 -07:00
test_normalize_disc_number.py Multi-disc: file the track in the disc folder that matches its tag (Sokhi) 2026-06-22 10:56:53 -07:00
test_quarantine_management.py #876: group quarantine alternatives by target track-id + auto-clear siblings on approve 2026-06-15 22:12:06 -07:00
test_rematch_apply.py #889 Phase 4: the Re-identify modal + apply backend 2026-06-18 15:37:56 -07:00
test_rematch_hints.py #889 Phase 1: re-identify hint store (DB table + pure create/find/consume seam) 2026-06-18 15:15:41 -07:00
test_rematch_hints_seam.py #889: FIX data loss — re-identify to the same release no longer deletes the file 2026-06-18 17:13:46 -07:00
test_rematch_search.py #889 Phase 3: re-identify search — multi-source track→release lookup + API 2026-06-18 15:31:33 -07:00
test_search_match_endpoints.py Deezer search: drop advanced-syntax at endpoint, free-text + rerank wins 2026-05-10 09:36:48 -07:00
test_single_to_album.py Library: wire single->album resolution into import detection (gated, fail-safe) 2026-06-18 09:30:11 -07:00
test_track_number_resolver.py Track "01" bug: recover real track position instead of fabricating 1 2026-06-15 23:35:48 -07:00
test_track_number_strip.py #890: strip leading track-number prefix from filename-derived titles 2026-06-18 18:35:04 -07:00
test_version_mismatch_fallback.py Downloads: opt-in last-resort acceptance of repeated version mismatches 2026-06-06 16:44:14 +02:00