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

60
tests/test_tagging.py Normal file
View File

@ -0,0 +1,60 @@
import pytest
from lintunes import tagging
FIELDS = {
"name": "Test Title",
"artist": "Test Artist",
"album_artist": "Test Album Artist",
"album": "Test Album",
"genre": "Electronic",
"composer": "Test Composer",
"comments": "A comment",
"grouping": "Test Group",
"year": 2021,
"track_number": 3,
"track_count": 12,
"disc_number": 1,
"disc_count": 2,
"compilation": True,
"bpm": 120,
}
@pytest.mark.parametrize("fixture", ["mp3_file", "m4a_file", "flac_file"])
def test_write_read_round_trip(fixture, request):
path = request.getfixturevalue(fixture)
tagging.write_tags(path, FIELDS)
read = tagging.read_tags(path)
for key in ("name", "artist", "album_artist", "album", "genre",
"composer", "comments"):
assert read.get(key) == FIELDS[key], key
assert read.get("year") == 2021
assert read.get("track_number") == 3
assert read.get("track_count") == 12
assert read.get("disc_number") == 1
assert read.get("total_time", 0) > 500 # ~1s of audio
assert read.get("size", 0) > 0
def test_read_tags_reports_audio_properties(mp3_file):
read = tagging.read_tags(mp3_file)
assert read.get("kind") == "MPEG audio file"
assert read.get("sample_rate", 0) > 0
def test_no_artwork_in_generated_file(mp3_file):
assert tagging.read_embedded_artwork(mp3_file) is None
@pytest.mark.parametrize("fixture", ["mp3_file", "m4a_file", "flac_file"])
def test_artwork_write_read_round_trip(fixture, request, jpeg_bytes):
path = request.getfixturevalue(fixture)
assert tagging.read_embedded_artwork(path) is None
tagging.write_artwork(path, jpeg_bytes, "image/jpeg")
assert tagging.read_embedded_artwork(path) == jpeg_bytes
# Replacing art works too (no duplicate covers accumulate)
tagging.write_artwork(path, jpeg_bytes + b"\x00", "image/jpeg")
assert tagging.read_embedded_artwork(path) == jpeg_bytes + b"\x00"