Files
ChatAIBot/tests/test_plot_choices.py
T
2026-06-04 08:05:06 +03:00

30 lines
990 B
Python

from services.rpg_plot import choices_from_beat, choices_from_narrator, normalize_choice
def test_choices_from_beat_tags_source():
beat = {
"id": "b_new_1",
"title": "Rest Stop Confession",
"injection": "GPS alerts you to a rest stop.",
"choices": [
{"id": "a", "label": "Tease her about snores"},
{"id": "b", "label": "Ask about snacks"},
],
}
out = choices_from_beat(beat)
assert len(out) == 2
assert out[0]["source"] == "plot_beat"
assert out[0]["beat_title"] == "Rest Stop Confession"
assert out[0]["beat_id"] == "b_new_1"
assert "beat_injection" in out[0]
def test_choices_from_narrator_tags_source():
out = choices_from_narrator([{"id": "a", "label": "Look around"}])
assert out[0]["source"] == "narrator"
assert "beat_title" not in out[0]
def test_normalize_choice_skips_empty_label():
assert normalize_choice({"id": "a", "label": " "}, source="narrator") is None