Files
DumasNodes/tests/test_dumas_h3_beat_prompt.py

74 lines
2.5 KiB
Python

import importlib
import unittest
class DumasH3BeatPromptTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.module = importlib.import_module("dumas_h3_beat_prompt")
def test_parse_state_falls_back_to_default(self):
state = self.module._parse_beat_prompt_state("not json")
self.assertEqual(
state,
{
"scene": "",
"character_sheet": "",
"beats": [{"text": "Describe this beat."}],
},
)
def test_assemble_prompt_outputs_upstream_sections(self):
prompt = self.module._assemble_beat_prompt(
{
"scene": "A rainy kitchen at night.",
"character_sheet": "Maya: 27, she, red jacket, silver hair.",
"beats": [
{"text": "Maya enters the room."},
{"text": "remove: red jacket\nadd: white shirt underneath\nShe sits at the table."},
{"text": " "},
]
}
)
self.assertEqual(
prompt,
(
"A rainy kitchen at night.\n\n"
"Maya: 27, she, red jacket, silver hair.\n\n"
"Maya enters the room.\n\n"
"remove: red jacket\nadd: white shirt underneath\nShe sits at the table."
),
)
def test_assemble_prompt_strips_old_dumas_directives(self):
prompt = self.module._assemble_beat_prompt(
{
"beats": [
{
"text": (
"seconds: 8\n"
"continuity: hard cut\n"
"ref_mode: every shot\n"
"soundscape: soft rain\n"
"music: low synth\n"
"Maya opens the cupboard.\n"
"remove: red jacket"
)
},
]
}
)
self.assertEqual(prompt, "Maya opens the cupboard.\nremove: red jacket")
def test_node_build_prompt_uses_hidden_state(self):
node = self.module.DumasH3BeatPromptNode()
result = node.build_prompt(
'{"scene":"Scene","character_sheet":"Maya: 27, she","beats":[{"text":"Beat one"},{"text":"Beat two"}]}'
)
self.assertEqual(result, ("Scene\n\nMaya: 27, she\n\nBeat one\n\nBeat two",))
if __name__ == "__main__":
unittest.main()