"""Tests for prompt registry.""" from __future__ import annotations import pytest from app.prompts.registry import get_prompt def test_get_prompt_returns_english_for_known_stage(): p = get_prompt("orchestrator_phase1", "en") assert isinstance(p, str) assert len(p) > 100 assert "Game Master" in p or "GM" in p def test_get_prompt_falls_back_to_english(): p = get_prompt("orchestrator_phase2", "ru") # Russian bundle is empty — falls back to English assert isinstance(p, str) assert len(p) > 100 def test_get_prompt_unknown_stage_raises(): with pytest.raises(KeyError): get_prompt("does_not_exist", "en") def test_all_stages_have_english_prompt(): stages = [ "world_builder_schema", "world_builder_env", "world_builder_entities", "world_editor", "orchestrator_phase1", "orchestrator_phase2", "orchestrator_phase3_summary", "orchestrator_phase3_suggest", "intro_scene", "subagent", "summary", ] for s in stages: p = get_prompt(s, "en") assert len(p) > 50, f"Stage {s} has empty prompt" def test_orchestrator_phase1_prompt_has_required_placeholders(): p = get_prompt("orchestrator_phase1", "en") for placeholder in [ "{world_name}", "{rules}", "{schemas_summary}", "{environment_json}", "{plot_rails_json}", "{current_time}", "{max_substeps}", "{player_action}", "{language}", "{recent_history}", ]: assert placeholder in p, f"Missing placeholder {placeholder}" def test_orchestrator_phase2_prompt_has_required_placeholders(): p = get_prompt("orchestrator_phase2", "en") for placeholder in [ "{world_name}", "{language}", "{current_time}", "{player_action}", "{plan}", "{summary_json}", "{environment_json}", "{world_description}", ]: assert placeholder in p, f"Missing placeholder {placeholder}"