Fix sanitize_filename consistency, add scanner server tests, remove stray file

- Unify sanitize_filename (organizer) and _sanitize_name (ripper): both now use
  whitelist approach — spaces→underscore, keep \w and hyphens, remove everything
  else (brackets, punctuation, commas, dots, …). _sanitize_name removed from
  ripper.py; ripper now imports sanitize_filename from organizer directly.
- Add tests/test_scanner_server.py: 15 tests covering HTTP GET/POST handlers,
  image upload queue, 404/400 error paths, _get_local_ip fallback, print_qr
  graceful degradation without qrcode installed.
- Delete empty stray file '3' from repo root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-19 14:20:03 +01:00
commit 7135e681f8
5 changed files with 258 additions and 51 deletions

View file

@ -17,16 +17,22 @@ class TestSanitizeFilename:
def test_replaces_spaces(self) -> None:
assert sanitize_filename("Hello World") == "Hello_World"
def test_replaces_punctuation(self) -> None:
def test_removes_punctuation(self) -> None:
assert sanitize_filename("Song (Live)") == "Song_Live"
assert sanitize_filename("Artist: Name") == "Artist_Name"
assert sanitize_filename("Vol. 2") == "Vol_2"
assert sanitize_filename("Hello, World!") == "Hello_World"
def test_keeps_hyphens(self) -> None:
assert sanitize_filename("AC-DC") == "AC-DC"
assert sanitize_filename("Sonata - Allegro") == "Sonata_-_Allegro"
def test_collapses_multiple_underscores(self) -> None:
assert sanitize_filename("A B") == "A_B"
assert sanitize_filename("A--B") == "A_B"
def test_strips_leading_trailing_underscores(self) -> None:
def test_strips_leading_trailing(self) -> None:
assert sanitize_filename("_Test_") == "Test"
assert sanitize_filename("-Test-") == "Test"
def test_keeps_umlauts(self) -> None:
assert sanitize_filename("Für Elise") == "Für_Elise"