test: delete slow, timing-based and redundant tests

This commit is contained in:
imSp4rky
2026-12-05 15:20:05 -07:00
parent 783a2fc185
commit 3a0a74e694
292 changed files with 153 additions and 15174 deletions
-104
View File
@@ -1,7 +1,6 @@
from collections.abc import Callable
from typing import Any
import jsonpickle
import pytest
from tests.lang_selection.test_kind_only_selection import FakeService, run
@@ -57,13 +56,6 @@ def test_a_collection_of_different_releases_shows_only_its_own_facts() -> None:
assert str(mixed(**OWN_FACTS)) == "Own Artist - Own Title (1990)"
def test_a_collection_of_different_releases_shows_the_date_and_quality_set_on_it() -> None:
music = mixed(**OWN_FACTS)
vars(music).update(release_date="1990-02-03", quality="MP3")
rows = dict(header(music))
assert (rows["Released"], rows["Quality"]) == ("February 3, 1990", "MP3")
@pytest.mark.parametrize(
("facts", "line"),
[
@@ -112,26 +104,6 @@ def test_a_collection_of_one_release_shows_the_facts_of_its_first_song(album_art
assert str(Album([song(1, "Album 1", album_artist, year=None)])) == f"{artist} - Album 1 (?)"
def test_a_collection_of_one_release_shows_its_own_facts_before_those_of_a_song() -> None:
facts = {**OWN_FACTS, "total_discs": 3, "total_duration": 4000}
music = Album([song(n, "Album 1", "Album Artist", explicit=True) for n in (1, 2)], **facts)
vars(music).update(released="1990-02-03", quality="MP3")
assert dict(header(music)) == {
"Title": "Own Title",
"Artist": "Own Artist",
"Type": "Playlist Explicit",
"Released": "February 3, 1990",
"Year": "1990",
"Tracks": "9",
"Discs": "3",
"Length": "1h 06m 40s",
"Quality": "MP3",
"Genre": "Genre 1",
"Label": "Label 1",
}
assert str(music) == "Own Artist - Own Title (1990)"
@pytest.mark.parametrize("nested", [False, True])
def test_the_first_song_of_one_release_gives_the_quality_flags(nested: bool) -> None:
data = {"lossless": True, "hires": True, "release_date": "2001-10-14"}
@@ -139,21 +111,6 @@ def test_the_first_song_of_one_release_gives_the_quality_flags(nested: bool) ->
assert (dict(header(music))["Quality"], dict(header(music))["Released"]) == ("Hi-Res Lossless", "October 14, 2001")
def test_a_blank_album_of_one_release_keeps_its_row() -> None:
music = Album([song(1, " ", "Album Artist")])
assert str(music) == "Album Artist - (2001)"
assert header(music)[0] == ("Title", "")
@pytest.mark.parametrize("duration", [10**400, float("inf"), "Infinity"], ids=["huge", "infinite", "text"])
def test_a_song_duration_too_large_to_convert_does_not_count(duration: Any) -> None:
music = Album([song(1, "Album 1", None), song(2, "Album 1", None, data={"duration": duration})])
assert dict(header(music))["Length"] == "1m 00s"
with console.capture() as out:
console.print(music.tree())
assert "Name 2" in out.get()
@pytest.mark.parametrize("field", ["title", "artist", "kind"])
def test_a_fact_is_text_and_not_markup(field: str) -> None:
with console.capture() as out:
@@ -161,55 +118,9 @@ def test_a_fact_is_text_and_not_markup(field: str) -> None:
assert "[red]x[/y] :cd:" in out.get().lower()
def test_a_collection_from_the_title_cache_shows_only_its_own_facts() -> None:
restored = jsonpickle.loads(jsonpickle.dumps(mixed(**OWN_FACTS)))
assert header(restored) == OWN_ROWS
assert str(restored) == "Own Artist - Own Title (1990)"
@pytest.mark.parametrize("field", ["year", "total_tracks", "total_discs", "total_duration"])
def test_a_collection_number_is_never_a_bool(field: str) -> None:
with pytest.raises(TypeError, match=f"Expected {field} to be an int, not True"):
Album([], **{field: True})
def test_a_total_duration_too_large_to_convert_is_shown_as_given() -> None:
assert MusicRenderer.format_total_duration(10**400) == str(10**400)
NOT_MARKUP = pytest.mark.parametrize("name", ["Live [red]set[/red]", "Live [/x]", "Live :cd:", "Live \\"])
@NOT_MARKUP
def test_the_title_line_shows_the_collection_as_given(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, name: str
) -> None:
service = FakeService({})
service.get_titles = lambda: mixed(artist="Own Artist", title=name) # type: ignore[assignment]
with console.capture() as out:
run(monkeypatch, caplog, {}, service=service, list_titles=True)
assert f" Album: Own Artist - {name} " in out.get()
@NOT_MARKUP
def test_the_track_line_shows_the_song_as_given(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, name: str
) -> None:
music = mixed()
music[0].name = name
service = FakeService({1: {}})
tracks = service.get_tracks(service.get_titles()[0])
service.get_titles = lambda: music # type: ignore[assignment]
service.get_tracks = lambda title: tracks # type: ignore[method-assign]
with console.capture() as out:
run(monkeypatch, caplog, {}, service=service)
assert f" Track 01: {name} " in out.get()
@pytest.mark.parametrize(
("label", "hires"),
[
@@ -301,21 +212,6 @@ def test_a_collection_of_different_releases_is_not_drawn_again(
assert "Quality" not in out
def test_the_header_is_drawn_again_once_per_release(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
) -> None:
music, tracks = flac_release()
higher = Tracks()
higher.add(
Audio(id_="b", url="https://x/b", language="en", codec=Audio.Codec.FLAC, bit_depth=24, sample_rate=192000)
)
out = run_release(monkeypatch, caplog, music, lambda title: tracks if title is music[0] else higher, to_end=True)
assert out.count("Length") == 2
assert music[0].data["sample_rate"] == 96000
def test_a_later_first_song_fills_the_release_song(
monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
) -> None: