TicTacToe tests: Extend tests to end of game draw condition & quit.
This commit is contained in:
parent
d686a3b337
commit
62d781a53e
|
@ -1,5 +1,7 @@
|
||||||
from zulip_bots.test_lib import StubBotTestCase
|
from zulip_bots.test_lib import StubBotTestCase
|
||||||
|
|
||||||
|
from mock import patch
|
||||||
|
|
||||||
class TestTictactoeBot(StubBotTestCase):
|
class TestTictactoeBot(StubBotTestCase):
|
||||||
bot_name = 'tictactoe'
|
bot_name = 'tictactoe'
|
||||||
|
|
||||||
|
@ -39,8 +41,10 @@ class TestTictactoeBot(StubBotTestCase):
|
||||||
"My turn:\n[ x o x ]\n[ x o _ ]\n[ o _ _ ]\n"
|
"My turn:\n[ x o x ]\n[ x o _ ]\n[ o _ _ ]\n"
|
||||||
"Your turn! Enter a coordinate or type help."),
|
"Your turn! Enter a coordinate or type help."),
|
||||||
after_3_2 = ("[ x o x ]\n[ x o _ ]\n[ o x _ ]\n"
|
after_3_2 = ("[ x o x ]\n[ x o _ ]\n[ o x _ ]\n"
|
||||||
"My turn:\n[ x o x ]\n[ x o o ]\n[ o x _ ]\n"
|
"My turn:\n[ x o x ]\n[ x o _ ]\n[ o x o ]\n"
|
||||||
"Your turn! Enter a coordinate or type help."),
|
"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.")
|
||||||
)
|
)
|
||||||
|
|
||||||
conversation = [
|
conversation = [
|
||||||
|
@ -80,8 +84,12 @@ class TestTictactoeBot(StubBotTestCase):
|
||||||
("1,1", msg['after_1_1']),
|
("1,1", msg['after_1_1']),
|
||||||
("2, 1", msg['after_2_1']),
|
("2, 1", msg['after_2_1']),
|
||||||
("(1,3)", msg['after_1_3']),
|
("(1,3)", msg['after_1_3']),
|
||||||
("quit", msg['successful_quit']),
|
("3,2", msg['after_3_2']),
|
||||||
# Can't test 'after_3_2' as it's random!
|
("2,3", msg['after_2_3_draw']),
|
||||||
|
# Game already over; can't quit FIXME improve response?
|
||||||
|
("quit", msg['didnt_understand']),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
with patch('zulip_bots.bots.tictactoe.tictactoe.random.choice') as choice:
|
||||||
|
choice.return_value = [2, 2]
|
||||||
self.verify_dialog(conversation)
|
self.verify_dialog(conversation)
|
||||||
|
|
Loading…
Reference in a new issue