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:
47
tests/test_relocate.py
Normal file
47
tests/test_relocate.py
Normal file
@ -0,0 +1,47 @@
|
||||
"""LibraryManager.set_track_location: repoint a track at a moved/renamed file.
|
||||
|
||||
It's a path repair, not a content edit — so it persists the new location and
|
||||
notifies the UI, but must not touch date_modified or write tags.
|
||||
"""
|
||||
|
||||
from lintunes.models import Library, Track
|
||||
from lintunes.library_manager import LibraryManager
|
||||
|
||||
|
||||
def _manager(tmp_path):
|
||||
track = Track(track_id=1, name="Song",
|
||||
location="/old/path/song.mp3",
|
||||
date_modified="2020-01-01T00:00:00")
|
||||
return LibraryManager(Library(tracks={1: track}), tmp_path), track
|
||||
|
||||
|
||||
def test_set_track_location_repoints_and_persists(qapp, tmp_path):
|
||||
manager, track = _manager(tmp_path)
|
||||
updates, edits = [], []
|
||||
manager.track_updated.connect(updates.append)
|
||||
manager.track_fields_edited.connect(lambda tid, fields: edits.append(tid))
|
||||
|
||||
manager.set_track_location(1, "/new/path/from there to here.mp3")
|
||||
|
||||
assert track.location == "/new/path/from there to here.mp3"
|
||||
assert manager._dirty_tracks # will be saved
|
||||
assert updates == [1] # UI refreshes the row
|
||||
assert edits == [] # not a metadata edit
|
||||
assert track.date_modified == "2020-01-01T00:00:00" # untouched
|
||||
|
||||
|
||||
def test_set_track_location_noop_when_unchanged(qapp, tmp_path):
|
||||
manager, track = _manager(tmp_path)
|
||||
updates = []
|
||||
manager.track_updated.connect(updates.append)
|
||||
|
||||
manager.set_track_location(1, track.location)
|
||||
|
||||
assert updates == []
|
||||
assert not manager._dirty_tracks
|
||||
|
||||
|
||||
def test_set_track_location_ignores_unknown_track(qapp, tmp_path):
|
||||
manager, _track = _manager(tmp_path)
|
||||
manager.set_track_location(999, "/whatever.mp3") # no such track
|
||||
assert not manager._dirty_tracks
|
||||
Reference in New Issue
Block a user