import json import pytest from ozan_radio.dj import parse_llm_json def test_parse_llm_json_plain(): data = parse_llm_json('{"title": "Test", "lyria_prompt": "one line"}') assert data["title"] == "Test" def test_parse_llm_json_fenced(): raw = '```json\n{"title": "Fenced"}\n```' assert parse_llm_json(raw)["title"] == "Fenced" def test_parse_llm_json_wrapped_text(): raw = 'Here is the plan:\n{"title": "Wrapped", "mood": "calm"}\nThanks.' assert parse_llm_json(raw)["title"] == "Wrapped" def test_parse_llm_json_invalid_raises(): with pytest.raises(json.JSONDecodeError): parse_llm_json("not json at all")