Commit fe838b82 authored by Aryan Noshirvani's avatar Aryan Noshirvani

Add real functional test coverage for every API endpoint

Every existing test file mostly covered validation-shape (missing
fields -> 422, unknown id -> 404) but not the actual success path with
real dummy data, and auth.py's one "success" test just accepted any of
[200, 400, 422, 500] since it hit the real Telegram API unmocked - not
really testing anything. Went through every router and added the
missing success-path coverage:

- auth.py: mock telegram_auth/telegram_sync instead of hitting real
  Telegram; test request_code and login (including that login actually
  creates a User row), chats and chat-music with a real session header
  (previously only the 401-no-token cases existed).
- discovery.py: /listen success path (mocked identify_audio, asserts
  a DiscoveredSong row is actually created) and the no-match case;
  /swipe success path (asserts `liked` is actually persisted, not just
  that invalid ids 404).
- library.py: /library/stream and /library/lyrics had zero test
  coverage at all - added success + 404 + (for stream) file-missing-
  on-disk cases; /playlists/{id}/add success path (asserts the
  PlaylistTrack row actually exists, not just that invalid ids 404).
- music.py: /music/upload success path - generates a real minimal MP3
  at test time (mutagen rejects garbage bytes, so a fake byte string
  isn't enough here), mocks identify_audio, verifies the response
  metadata and that the tagged file actually lands in downloads/.
- social.py: added the one endpoint with no test at all,
  /social/posts/{id}/tree (both the 404 and the with-children case).

44 tests total (up from 24), full run still ~1s since everything
external is mocked - no real network calls anywhere in the suite.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi
parent aaad56ac
Pipeline #990 failed with stage
in 6 minutes and 50 seconds