mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -12,9 +12,6 @@ from unshackle.core.music.extract import (
|
||||
duration_seconds,
|
||||
first_number,
|
||||
first_text,
|
||||
format_duration,
|
||||
format_names,
|
||||
year_from_value,
|
||||
)
|
||||
from unshackle.core.titles.music import Music, Song
|
||||
|
||||
@@ -86,21 +83,6 @@ def test_first_number(values: tuple[Any, ...], expected: float | None) -> None:
|
||||
assert first_number(*values) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("value", "expected"),
|
||||
[
|
||||
("2021-05-04", 2021),
|
||||
("released 1999 remaster", 1999),
|
||||
(2018, 2018),
|
||||
("no year here", 1900),
|
||||
(None, 1900),
|
||||
("", 1900),
|
||||
],
|
||||
)
|
||||
def test_year_from_value(value: Any, expected: int) -> None:
|
||||
assert year_from_value(value) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("value", "expected"),
|
||||
[
|
||||
@@ -115,39 +97,6 @@ def test_duration_seconds(value: Any, expected: float | None) -> None:
|
||||
assert duration_seconds(value) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("value", "expected"),
|
||||
[
|
||||
(0, "0:00"),
|
||||
(5, "0:05"),
|
||||
(65, "1:05"),
|
||||
(599, "9:59"),
|
||||
(3600, "1:00:00"),
|
||||
(3725, "1:02:05"),
|
||||
(-5, "0:00"),
|
||||
(None, ""),
|
||||
("bad", ""),
|
||||
(float("inf"), ""),
|
||||
],
|
||||
)
|
||||
def test_format_duration(value: Any, expected: str) -> None:
|
||||
assert format_duration(value) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("value", "sep", "expected"),
|
||||
[
|
||||
(["Alice", "Bob"], ", ", "Alice, Bob"),
|
||||
(["Alice", "Alice"], ", ", "Alice"), # de-dupes
|
||||
([{"profile": {"name": "DJ"}}], ", ", "DJ"),
|
||||
({"items": [{"name": "X"}, {"name": "Y"}]}, " & ", "X & Y"),
|
||||
("Solo", ", ", "Solo"),
|
||||
],
|
||||
)
|
||||
def test_format_names(value: Any, sep: str, expected: str) -> None:
|
||||
assert format_names(value, sep=sep) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("raw_kind", "count", "expected"),
|
||||
[
|
||||
@@ -211,22 +160,6 @@ def test_build_music_from_songs() -> None:
|
||||
assert music.artwork_url == "http://art/1.jpg"
|
||||
|
||||
|
||||
def test_build_music_from_songs_overrides() -> None:
|
||||
songs = [make_song(data={"duration": 60})]
|
||||
music = build_music_from_songs(
|
||||
songs,
|
||||
kind="playlist",
|
||||
title="My Mix",
|
||||
artist="Various",
|
||||
owner="george",
|
||||
description="best of",
|
||||
)
|
||||
assert music.title == "My Mix"
|
||||
assert music.artist == "Various"
|
||||
assert music.owner == "george"
|
||||
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"),
|
||||
@@ -238,8 +171,3 @@ def test_build_music_from_songs_of_different_releases_takes_no_fact_from_a_song(
|
||||
|
||||
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