Something went wrong. Try again.
A 5e storytelling engine with an LLM DM
Something went wrong. Try again.
Python
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475"""Tests for CLI helpers — cold-start detection and onboarding artifacts."""
import pytest
from storied.character import create_characterfrom storied.cli import _is_cold_startfrom storied.paths import world_path
@pytest.fixturedef _minimal_character() -> None: """Create a minimal character so load_character finds one.""" create_character( player_id="default", name="Test", race="Human", char_class="Fighter", level=1, abilities={ "strength": 10, "dexterity": 10, "constitution": 10, "intelligence": 10, "wisdom": 10, "charisma": 10, }, hp_max=10, ac=10, )
@pytest.fixturedef _world_style() -> None: """Write a non-empty style.md for the default world.""" world_dir = world_path("default") world_dir.mkdir(parents=True, exist_ok=True) (world_dir / "style.md").write_text("Grim. Slow-burn.\n")
class TestColdStartDetection: def test_cold_start_when_nothing_exists(self): assert _is_cold_start("default", "default") is True
@pytest.mark.usefixtures("_minimal_character") def test_cold_start_when_only_character_exists(self): assert _is_cold_start("default", "default") is True
@pytest.mark.usefixtures("_world_style") def test_cold_start_when_only_style_exists(self): assert _is_cold_start("default", "default") is True
@pytest.mark.usefixtures("_minimal_character", "_world_style") def test_not_cold_start_when_both_exist(self): assert _is_cold_start("default", "default") is False
@pytest.mark.usefixtures("_minimal_character") def test_not_cold_start_ignores_other_worlds(self): # Style lives in a different world — doesn't count for this one. world_dir = world_path("other") world_dir.mkdir(parents=True, exist_ok=True) (world_dir / "style.md").write_text("A vibe.\n")
assert _is_cold_start("default", "default") is True
class TestOnboardingPromptExists: def test_new_game_prompt_file_exists(self): from storied.engine import load_prompt
content = load_prompt("new-game") # Sanity check: the prompt mentions both onboarding deliverables. assert "tune" in content assert "create_character" in content assert "end_session" in content