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>
This commit is contained in:
2026-06-26 21:12:01 -04:00
commit f6d35fa594
70 changed files with 8992 additions and 0 deletions

59
tests/test_round6.py Normal file
View File

@ -0,0 +1,59 @@
from lintunes.gui.playlist_ops import (
has_duplicates, filter_for_add, add_tracks_with_dup_check)
from lintunes.library_manager import LibraryManager
from lintunes.models import Library, Track, Playlist
class TestHasDuplicates:
def test_none_present(self):
assert has_duplicates([3, 4], [1, 2]) is False
def test_some_present(self):
assert has_duplicates([2, 3], [1, 2]) is True
def test_empty_incoming(self):
assert has_duplicates([], [1, 2]) is False
class TestFilterForAdd:
def test_add_duplicates_keeps_all_in_order(self):
assert filter_for_add([2, 3, 1], [1, 2], add_duplicates=True) == [2, 3, 1]
def test_skip_drops_existing_preserves_order(self):
assert filter_for_add([2, 3, 1], [1, 2], add_duplicates=False) == [3]
def test_skip_can_drop_everything(self):
assert filter_for_add([1, 2], [1, 2], add_duplicates=False) == []
def _manager_with(qapp, tmp_path, track_ids, playlist_track_ids=()):
library = Library()
for tid in track_ids:
library.tracks[tid] = Track(track_id=tid, name=f"t{tid}")
playlist = Playlist(name="PL", persistent_id="PID",
track_ids=list(playlist_track_ids))
library.playlists["PID"] = playlist
manager = LibraryManager(library, tmp_path)
return manager, playlist
class TestAddTracksWithDupCheck:
def test_no_duplicates_adds_all_without_prompt(self, qapp, tmp_path):
manager, playlist = _manager_with(qapp, tmp_path, [1, 2, 3], [1])
added = add_tracks_with_dup_check(manager, None, "PID", [2, 3])
assert added == [2, 3]
assert playlist.track_ids == [1, 2, 3]
def test_position_inserts_in_place(self, qapp, tmp_path):
manager, playlist = _manager_with(qapp, tmp_path, [1, 2, 3], [1, 3])
add_tracks_with_dup_check(manager, None, "PID", [2], position=1)
assert playlist.track_ids == [1, 2, 3]
def test_empty_input_is_noop(self, qapp, tmp_path):
manager, playlist = _manager_with(qapp, tmp_path, [1], [1])
assert add_tracks_with_dup_check(manager, None, "PID", []) == []
assert playlist.track_ids == [1]
def test_unknown_playlist_is_noop(self, qapp, tmp_path):
manager, _ = _manager_with(qapp, tmp_path, [1], [])
assert add_tracks_with_dup_check(manager, None, "NOPE", [1]) == []