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>
37 lines
1 KiB
Python
37 lines
1 KiB
Python
"""Tests für die Vision-LLM JSON-Extraktion."""
|
|
|
|
import pytest
|
|
|
|
from musiksammlung.vision_llm import _extract_json
|
|
|
|
|
|
def test_extract_pure_json():
|
|
text = '{"artist": "Test", "album": "Album"}'
|
|
assert '"Test"' in _extract_json(text)
|
|
|
|
|
|
def test_extract_json_from_markdown_block():
|
|
text = 'Hier ist das Ergebnis:\n```json\n{"artist": "Test"}\n```\nFertig.'
|
|
assert '"Test"' in _extract_json(text)
|
|
|
|
|
|
def test_extract_json_with_thinking_tags():
|
|
text = '<think>Ich denke nach...</think>\n{"artist": "Test", "album": "X"}'
|
|
result = _extract_json(text)
|
|
assert '"Test"' in result
|
|
|
|
|
|
def test_extract_json_with_surrounding_text():
|
|
text = 'Das JSON:\n{"artist": "A", "album": "B"}\nEnde.'
|
|
result = _extract_json(text)
|
|
assert '"A"' in result
|
|
|
|
|
|
def test_extract_json_empty_raises():
|
|
with pytest.raises(ValueError, match="Leere Antwort"):
|
|
_extract_json("")
|
|
|
|
|
|
def test_extract_json_no_json_raises():
|
|
with pytest.raises(ValueError, match="Kein JSON"):
|
|
_extract_json("Hier ist kein JSON, nur Text.")
|