Slice 4: Integration tests for rename_chapters pipeline wiring #35

Closed
opened 2026-06-05 15:04:13 +02:00 by AlexKucera · 1 comment
AlexKucera commented 2026-06-05 15:04:13 +02:00 (Migrated from github.com)

Parent

#19

What to build

End-to-end integration tests proving that rename_chapters() fires correctly through the full download pipeline for each format strategy, and is properly suppressed when disabled.

End-to-end behavior: Tests exercise the full download_book() → _download_mp3() → rename_chapters() path using mock HTTP transports (existing pattern from TestFormatStrategy in test_downloader.py). Each test sets up a mock manifest with tracks, a mock ZIP part containing MP3 files, calls download_book(), and asserts on the resulting filenames in the output directory.

Test scenarios:

  1. mp3_only + rename enabled → MP3s extracted AND renamed to chapter titles
  2. m4b_mp3_fallback + MP3 fallback + rename enabled → MP3s extracted AND renamed
  3. m4b_mp3_fallback + M4B success + rename enabled → M4B downloaded, rename NOT called
  4. m4b_only + rename enabled → M4B downloaded, rename NOT called
  5. mp3_only + --no-rename-chapters → MP3s extracted but NOT renamed (original names kept)
  6. Verbose output includes rename log lines when rename fires

These tests use the existing mock transport / ZIP fixture patterns from TestFormatStrategy (_make_mp3_zip(), custom transport with manifest responses).

Acceptance criteria

  • mp3_only + rename_chapters=True → extracted files have chapter-based names
  • m4b_mp3_fallback (MP3 fallback) + rename_chapters=True → extracted files have chapter-based names
  • m4b_mp3_fallback (M4B success) + rename_chapters=True → no rename side effects
  • m4b_only + rename_chapters=True → no rename side effects
  • mp3_only + rename_chapters=False → extracted files keep original names
  • Verbose mode logs rename operations
  • All new tests pass alongside existing ~374 tests

Blocked by

  • #34 (pipeline wiring must be complete before testing it)
## Parent #19 ## What to build End-to-end integration tests proving that `rename_chapters()` fires correctly through the full download pipeline for each format strategy, and is properly suppressed when disabled. **End-to-end behavior:** Tests exercise the full `download_book()` → `_download_mp3()` → `rename_chapters()` path using mock HTTP transports (existing pattern from `TestFormatStrategy` in test_downloader.py). Each test sets up a mock manifest with tracks, a mock ZIP part containing MP3 files, calls `download_book()`, and asserts on the resulting filenames in the output directory. **Test scenarios:** 1. **mp3_only + rename enabled** → MP3s extracted AND renamed to chapter titles 2. **m4b_mp3_fallback + MP3 fallback + rename enabled** → MP3s extracted AND renamed 3. **m4b_mp3_fallback + M4B success + rename enabled** → M4B downloaded, rename NOT called 4. **m4b_only + rename enabled** → M4B downloaded, rename NOT called 5. **mp3_only + --no-rename-chapters** → MP3s extracted but NOT renamed (original names kept) 6. **Verbose output includes rename log lines** when rename fires These tests use the existing mock transport / ZIP fixture patterns from `TestFormatStrategy` (`_make_mp3_zip()`, custom transport with manifest responses). ## Acceptance criteria - [ ] mp3_only + rename_chapters=True → extracted files have chapter-based names - [ ] m4b_mp3_fallback (MP3 fallback) + rename_chapters=True → extracted files have chapter-based names - [ ] m4b_mp3_fallback (M4B success) + rename_chapters=True → no rename side effects - [ ] m4b_only + rename_chapters=True → no rename side effects - [ ] mp3_only + rename_chapters=False → extracted files keep original names - [ ] Verbose mode logs rename operations - [ ] All new tests pass alongside existing ~374 tests ## Blocked by - #34 (pipeline wiring must be complete before testing it)
AlexKucera commented 2026-06-05 17:56:15 +02:00 (Migrated from github.com)

✅ All 6/6 acceptance criteria met — 4 new integration tests added (1 missing AC#3 + 3 edge cases including 105-chapter 3-digit padding). ~233 tests pass.

✅ All 6/6 acceptance criteria met — 4 new integration tests added (1 missing AC#3 + 3 edge cases including 105-chapter 3-digit padding). ~233 tests pass.
Sign in to join this conversation.