Something went wrong. Try again.
A 5e storytelling engine with an LLM DM
Something went wrong. Try again.
Python
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697"""Tests for the DM style tuning system and the arc commit tool."""
from pathlib import Path
from storied.testing import call_toolfrom storied.tools import ToolContextfrom storied.tools.scene import commit_arc as _commit_arcfrom storied.tools.scene import tune as _tune
def tune(tuning: str) -> str: return call_tool(_tune, tuning=tuning)
def commit_arc(content: str) -> str: return call_tool(_commit_arc, content=content)
class TestTune: """Tests for the tune tool."""
def test_tune_creates_style_file(self, ctx: ToolContext, tmp_path: Path): tune("Lean into intrigue and social encounters.")
style_path = tmp_path / "worlds" / ctx.world_id / "style.md" assert style_path.exists()
def test_tune_writes_content(self, ctx: ToolContext, tmp_path: Path): tune("More exploration, less combat.")
content = (tmp_path / "worlds" / ctx.world_id / "style.md").read_text() assert "More exploration, less combat." in content
def test_tune_has_heading(self, ctx: ToolContext, tmp_path: Path): tune("Keep pacing slow.")
content = (tmp_path / "worlds" / ctx.world_id / "style.md").read_text() assert content.startswith("# Style\n")
def test_tune_replaces_existing(self, ctx: ToolContext, tmp_path: Path): tune("Lots of combat.") tune("Actually, less combat.")
content = (tmp_path / "worlds" / ctx.world_id / "style.md").read_text() assert "Actually, less combat." in content assert "Lots of combat." not in content
def test_tune_returns_confirmation(self, ctx: ToolContext): result = tune("Dark and atmospheric tone.")
assert "updated" in result.lower()
class TestCommitArc: """Tests for the arc_architect's commit_arc tool."""
def test_commit_arc_creates_arc_file( self, ctx: ToolContext, tmp_path: Path, ): commit_arc("# Campaign Arc\n\n## Premise\nA quiet mystery.\n")
arc_path = tmp_path / "worlds" / ctx.world_id / "arc.md" assert arc_path.exists()
def test_commit_arc_writes_content_verbatim( self, ctx: ToolContext, tmp_path: Path, ): content = ( "# Campaign Arc\n\n## Premise\nA wedding postponed twice.\n" "\n## Off the Table\n- the cosmic-prisoner trope\n" ) commit_arc(content)
arc_path = tmp_path / "worlds" / ctx.world_id / "arc.md" assert arc_path.read_text() == content
def test_commit_arc_replaces_existing( self, ctx: ToolContext, tmp_path: Path, ): commit_arc("# Campaign Arc\n\n## Premise\nFirst draft.\n") commit_arc("# Campaign Arc\n\n## Premise\nSecond draft.\n")
content = (tmp_path / "worlds" / ctx.world_id / "arc.md").read_text() assert "Second draft." in content assert "First draft." not in content
def test_commit_arc_returns_confirmation(self, ctx: ToolContext): result = commit_arc("# Campaign Arc\n\n## Premise\nA test.\n")
assert "committed" in result.lower()