From 969b984b807293672977343266779aca3d9e1349 Mon Sep 17 00:00:00 2001 From: "neiljp (Neil Pilgrim)" Date: Sun, 10 Dec 2017 12:19:01 -0800 Subject: [PATCH] TicTacToe tests: Extend tests to end of game lose condition & quit. --- .../zulip_bots/bots/tictactoe/test_tictactoe.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py b/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py index c8f6b03..360e444 100644 --- a/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py +++ b/zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py @@ -44,7 +44,13 @@ class TestTictactoeBot(StubBotTestCase): "My turn:\n[ x o x ]\n[ x o _ ]\n[ o x o ]\n" "Your turn! Enter a coordinate or type help."), after_2_3_draw = ("[ x o x ]\n[ x o x ]\n[ o x o ]\n" - "It's a draw! Neither of us was able to win.") + "It's a draw! Neither of us was able to win."), + after_2_3_try_lose = ("[ x _ _ ]\n[ _ o x ]\n[ _ _ _ ]\n" + "My turn:\n[ x _ _ ]\n[ _ o x ]\n[ _ o _ ]\n" + "Your turn! Enter a coordinate or type help."), + after_2_1_lost = ("[ x _ _ ]\n[ x o x ]\n[ _ o _ ]\n" + "My turn:\n[ x o _ ]\n[ x o x ]\n[ _ o _ ]\n" + "Game over! I've won!"), ) conversation = [ @@ -88,6 +94,12 @@ class TestTictactoeBot(StubBotTestCase): ("2,3", msg['after_2_3_draw']), # Game already over; can't quit FIXME improve response? ("quit", msg['didnt_understand']), + ("new", msg['new_game']), + ("1,1", msg['after_1_1']), + ("2,3", msg['after_2_3_try_lose']), + ("2,1", msg['after_2_1_lost']), + # Game already over; can't quit FIXME improve response? + ("quit", msg['didnt_understand']), ] with patch('zulip_bots.bots.tictactoe.tictactoe.random.choice') as choice: