mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-01 21:45:10 +00:00
fix(music): show a collection's own facts in the listing and over --remote
This commit is contained in:
@@ -79,6 +79,7 @@ def test_first_text(values: tuple[Any, ...], default: str, expected: str) -> Non
|
||||
(("abc", 7), 7.0),
|
||||
((None, ""), None),
|
||||
((), None),
|
||||
((10**400, "Infinity", float("nan"), 7), 7.0),
|
||||
],
|
||||
)
|
||||
def test_first_number(values: tuple[Any, ...], expected: float | None) -> None:
|
||||
@@ -126,6 +127,7 @@ def test_duration_seconds(value: Any, expected: float | None) -> None:
|
||||
(-5, "0:00"),
|
||||
(None, ""),
|
||||
("bad", ""),
|
||||
(float("inf"), ""),
|
||||
],
|
||||
)
|
||||
def test_format_duration(value: Any, expected: str) -> None:
|
||||
@@ -189,6 +191,7 @@ def test_build_music_from_songs() -> None:
|
||||
year=2019,
|
||||
album="Greatest",
|
||||
artist="Band",
|
||||
album_artist="The Band",
|
||||
total_tracks=2,
|
||||
total_discs=1,
|
||||
data={"duration": 100},
|
||||
@@ -224,6 +227,19 @@ def test_build_music_from_songs_overrides() -> None:
|
||||
assert music.description == "best of"
|
||||
|
||||
|
||||
def test_build_music_from_songs_of_different_releases_takes_no_fact_from_a_song() -> None:
|
||||
songs = [
|
||||
make_song(album="A", album_artist="Band A", total_tracks=30, artwork_url="http://art/a.jpg"),
|
||||
make_song(track=12, disc=4, album="B", album_artist="Band B", total_discs=4, data={"duration": 60}),
|
||||
]
|
||||
music = build_music_from_songs(songs, kind="playlist")
|
||||
assert (music.title, music.artist, music.year, music.artwork_url) == (None, None, None, None)
|
||||
assert (music.total_tracks, music.total_discs, music.total_duration) == (2, None, 60)
|
||||
|
||||
named = build_music_from_songs(songs, kind="playlist", title="My Mix", artist="Various")
|
||||
assert str(named) == "Various - My Mix"
|
||||
|
||||
|
||||
def test_build_music_from_songs_empty_raises() -> None:
|
||||
with pytest.raises(ValueError, match="nothing here"):
|
||||
build_music_from_songs([], kind="album", empty_error="nothing here")
|
||||
|
||||
Reference in New Issue
Block a user