46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""Tests for compact taste profile construction."""
|
|
|
|
from app.domain.models import TasteProfile, Track
|
|
from app.domain.profile import compress_taste_profile
|
|
|
|
|
|
def test_profile_compression_includes_bounded_signals_and_known_ids() -> None:
|
|
short_track = _track("short", "Quick Song", "Quick Artist")
|
|
long_track = _track("long", "Lasting Song", "Lasting Artist")
|
|
saved_track = _track("saved", "Saved Song", "Saved Artist")
|
|
profile = TasteProfile(
|
|
short_term_artists=("Current Artist",),
|
|
long_term_artists=("Enduring Artist",),
|
|
short_term_tracks=(short_track,),
|
|
long_term_tracks=(long_track,),
|
|
saved_tracks=(saved_track,),
|
|
)
|
|
|
|
compressed = compress_taste_profile(profile)
|
|
|
|
assert compressed.text.splitlines() == [
|
|
"Short-term top artists: Current Artist",
|
|
"Long-term top artists: Enduring Artist",
|
|
"Short-term top tracks: Quick Song by Quick Artist",
|
|
"Long-term top tracks: Lasting Song by Lasting Artist",
|
|
"Saved-track sample: Saved Song by Saved Artist",
|
|
]
|
|
assert compressed.known_track_ids == frozenset({"short", "long", "saved"})
|
|
|
|
|
|
def test_empty_profile_sections_are_explicit() -> None:
|
|
profile = TasteProfile((), (), (), (), ())
|
|
|
|
assert compress_taste_profile(profile).text.count(": none") == 5
|
|
|
|
|
|
def _track(track_id: str, title: str, artist: str) -> Track:
|
|
return Track(
|
|
id=track_id,
|
|
uri=f"spotify:track:{track_id}",
|
|
title=title,
|
|
artists=(artist,),
|
|
album_name="Album",
|
|
album_art_url=None,
|
|
external_url=None,
|
|
)
|