47 lines
1.4 KiB
Python
47 lines
1.4 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,
|
|
{"beats": [{"text": "Describe this beat."}]},
|
|
)
|
|
|
|
def test_assemble_prompt_joins_beats_with_blank_lines(self):
|
|
prompt = self.module._assemble_beat_prompt(
|
|
{
|
|
"beats": [
|
|
{"text": "A woman enters the room."},
|
|
{"text": "wardrobe: Maya = red jacket\nShe sits at the table."},
|
|
{"text": " "},
|
|
{"text": "music: low synth pulse"},
|
|
]
|
|
}
|
|
)
|
|
self.assertEqual(
|
|
prompt,
|
|
(
|
|
"A woman enters the room.\n\n"
|
|
"wardrobe: Maya = red jacket\nShe sits at the table.\n\n"
|
|
"music: low synth pulse"
|
|
),
|
|
)
|
|
|
|
def test_node_build_prompt_uses_hidden_state(self):
|
|
node = self.module.DumasH3BeatPromptNode()
|
|
result = node.build_prompt(
|
|
'{"beats":[{"text":"Beat one"},{"text":"Beat two"}]}'
|
|
)
|
|
self.assertEqual(result, ("Beat one\n\nBeat two",))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|