Files
lintunes/tests/test_round5.py
Trav f6d35fa594 Import existing LinTunes project
Snapshot of the existing codebase before working through the TASKS.md
backlog. Real library data (data/) and the iTunes import fixture
(itunes-test-library/) are gitignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 21:12:01 -04:00

47 lines
1.6 KiB
Python

from lintunes.gui.track_table import format_total_time
from lintunes.gui.library_view import _canonical_values, _artist_sort_key
class TestFormatTotalTime:
def test_minutes_seconds(self):
assert format_total_time((14 * 60 + 21) * 1000) == "14:21"
def test_hours(self):
ms = (9 * 3600 + 47 * 60 + 33) * 1000
assert format_total_time(ms) == "9:47:33"
def test_days_zero_pads_lower_units(self):
ms = (24 * 86400 + 18 * 3600 + 42 * 60 + 7) * 1000
assert format_total_time(ms) == "24:18:42:07"
def test_zero_keeps_min_sec(self):
assert format_total_time(0) == "0:00"
class TestCanonicalValues:
def test_most_tracks_spelling_wins(self):
values = ["The Beatles", "The Beatles", "the beatles"]
assert _canonical_values(values) == ["The Beatles"]
def test_tie_breaks_on_more_capitals(self):
# equal counts -> the spelling with more uppercase letters wins
assert _canonical_values(["abc", "ABC"]) == ["ABC"]
def test_distinct_names_preserved(self):
result = sorted(_canonical_values(["Beat Happening", "The Beatles"]))
assert result == ["Beat Happening", "The Beatles"]
class TestArtistSortKey:
def test_strips_leading_the(self):
assert _artist_sort_key("The Beatles") == "beatles"
def test_files_next_to_neighbor(self):
# "The Beatles" should sort adjacent to "Beat Happening"
names = ["The Beatles", "Beat Happening", "Beck"]
assert sorted(names, key=_artist_sort_key) == [
"Beat Happening", "The Beatles", "Beck"]
def test_no_article_unchanged(self):
assert _artist_sort_key("Beck") == "beck"