Remove tests/ from .gitignore (was accidentally excluded). - test_ripper.py: rewrite for current API (_parse_cddb_lines, _extract_tracks, _rename_files, _clean_input); fix default quality - test_organizer.py: update filename assertions (spaces→underscores); add TestSanitizeFilename, TestCheckDiscCounts, in-place mode - test_playlist.py: fix dummy filenames to underscore scheme; add multi-disc, filename sanitization, EXTINF and fallback tests Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Tests für die Datenmodelle."""
|
|
|
|
from musiksammlung.models import Album
|
|
|
|
|
|
def test_album_folder_name_with_year():
|
|
album = Album(artist="Test", album="Mein Album", year=1987, discs=[])
|
|
assert album.folder_name == "Mein Album (1987)"
|
|
|
|
|
|
def test_album_folder_name_without_year():
|
|
album = Album(artist="Test", album="Mein Album", year=None, discs=[])
|
|
assert album.folder_name == "Mein Album"
|
|
|
|
|
|
def test_sanitize_name():
|
|
album = Album(artist='Art:ist', album='Al/bum?', year=None, discs=[])
|
|
assert ":" not in album.artist
|
|
assert "/" not in album.album
|
|
assert "?" not in album.album
|
|
|
|
|
|
def test_album_from_json():
|
|
data = {
|
|
"artist": "Die Toten Hosen",
|
|
"album": "Opium fürs Volk",
|
|
"year": 1996,
|
|
"discs": [
|
|
{
|
|
"disc_number": 1,
|
|
"tracks": [
|
|
{"track_number": 1, "title": "Bonnie & Clyde"},
|
|
{"track_number": 2, "title": "Zehn kleine Jägermeister"},
|
|
],
|
|
}
|
|
],
|
|
}
|
|
album = Album.model_validate(data)
|
|
assert album.artist == "Die Toten Hosen"
|
|
assert len(album.discs) == 1
|
|
assert len(album.discs[0].tracks) == 2
|
|
assert album.discs[0].tracks[1].title == "Zehn kleine Jägermeister"
|