Fix and expand tests: 63 tests passing, covers all core modules
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>
This commit is contained in:
parent
734bc80b79
commit
775f274d02
7 changed files with 637 additions and 1 deletions
42
tests/test_models.py
Normal file
42
tests/test_models.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
"""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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue