diff --git a/bin/judge_replay/test_offline.py b/bin/judge_replay/test_offline.py index 020498a8..3d551738 100644 --- a/bin/judge_replay/test_offline.py +++ b/bin/judge_replay/test_offline.py @@ -7,7 +7,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from transcript_archive.outcomes import ANSWERED, FINISHED, INTERRUPTED, UNFINISHED from claude_code.entries import AssistantTurn, HumanTurn, Text, ToolCall -from judge_replay.offline import classifier, decision_table, evaluate, final_message, folds_of, LEARNERS, offline_report, question_mark, RULES, Sample +from judge_replay.offline import classifier, decision_table, evaluate, final_message, folds_of, LEARNERS, offline_report, question_mark, RULES, Sample, words_of def turn(*parts): @@ -23,10 +23,18 @@ class FinalMessage(unittest.TestCase): entries = [turn(Text("first")), HumanTurn(text="ok"), turn(Text("Done. Merged."), ToolCall("1", "Bash", {})), turn(ToolCall("2", "Bash", {}))] self.assertEqual(final_message(entries), "Done. Merged.") + def test_joins_the_texts_of_one_turn_on_separate_lines_and_leaves_out_blank_ones(self): + self.assertEqual(final_message([turn(Text("Merged."), Text(" "), Text("Which one?"))]), "Merged.\nWhich one?") + def test_is_empty_where_the_worker_wrote_no_text(self): self.assertEqual(final_message([HumanTurn(text="hi"), turn(ToolCall("1", "Bash", {}))]), "") +class WordsOf(unittest.TestCase): + def test_is_each_lowercase_word_each_pair_of_neighbours_and_each_question_mark(self): + self.assertEqual(words_of("Which one? Yes"), {"which", "one", "?", "yes", "which one", "one ?", "? yes"}) + + class QuestionMark(unittest.TestCase): def test_decides_interrupt_on_a_question_mark_and_finished_on_none(self): decide = question_mark([])