You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: zulip_bots/zulip_bots/bots/tictactoe/test_tictactoe.py
+57-9Lines changed: 57 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -28,17 +28,65 @@ def test_bot(self):
28
28
'subject': '[email protected]', # FIXME Requiring this in bot is a bug?
29
29
}
30
30
31
-
help_txt="*Help for Tic-Tac-Toe bot* \nThe bot responds to messages starting with @mention-bot.\n**@mention-bot new** will start a new game (but not if you're already in the middle of a game). You must type this first to start playing!\n**@mention-bot help** will return this help function.\n**@mention-bot quit** will quit from the current game.\n**@mention-bot <coordinate>** will make a move at the given coordinate.\nCoordinates are entered in a (row, column) format. Numbering is from top to bottom and left to right. \nHere are the coordinates of each position. (Parentheses and spaces are optional). \n(1, 1) (1, 2) (1, 3) \n(2, 1) (2, 2) (2, 3) \n(3, 1) (3, 2) (3, 3) \n"
32
-
didnt_understand_txt="Hmm, I didn't understand your input. Type **@tictactoe help** or **@ttt help** to see valid inputs."
33
-
new_game_txt="Welcome to tic-tac-toe! You'll be x's and I'll be o's. Your move first!\nCoordinates are entered in a (row, column) format. Numbering is from top to bottom and left to right.\nHere are the coordinates of each position. (Parentheses and spaces are optional.) \n(1, 1) (1, 2) (1, 3) \n(2, 1) (2, 2) (2, 3) \n(3, 1) (3, 2) (3, 3) \n Your move would be one of these. To make a move, type @mention-bot followed by a space and the coordinate."
31
+
msg=dict(
32
+
help="*Help for Tic-Tac-Toe bot* \nThe bot responds to messages starting with @mention-bot.\n**@mention-bot new** will start a new game (but not if you're already in the middle of a game). You must type this first to start playing!\n**@mention-bot help** will return this help function.\n**@mention-bot quit** will quit from the current game.\n**@mention-bot <coordinate>** will make a move at the given coordinate.\nCoordinates are entered in a (row, column) format. Numbering is from top to bottom and left to right. \nHere are the coordinates of each position. (Parentheses and spaces are optional). \n(1, 1) (1, 2) (1, 3) \n(2, 1) (2, 2) (2, 3) \n(3, 1) (3, 2) (3, 3) \n",
33
+
didnt_understand="Hmm, I didn't understand your input. Type **@tictactoe help** or **@ttt help** to see valid inputs.",
34
+
new_game="Welcome to tic-tac-toe! You'll be x's and I'll be o's. Your move first!\nCoordinates are entered in a (row, column) format. Numbering is from top to bottom and left to right.\nHere are the coordinates of each position. (Parentheses and spaces are optional.) \n(1, 1) (1, 2) (1, 3) \n(2, 1) (2, 2) (2, 3) \n(3, 1) (3, 2) (3, 3) \n Your move would be one of these. To make a move, type @mention-bot followed by a space and the coordinate.",
35
+
already_playing="You're already playing a game! Type **@tictactoe help** or **@ttt help** to see valid inputs.",
36
+
already_played_there='That space is already filled, sorry!',
37
+
successful_quit="You've successfully quit the game.",
38
+
after_1_1= ("[ x _ _ ]\n[ _ _ _ ]\n[ _ _ _ ]\n"
39
+
"My turn:\n[ x _ _ ]\n[ _ o _ ]\n[ _ _ _ ]\n"
40
+
"Your turn! Enter a coordinate or type help."),
41
+
after_2_1= ("[ x _ _ ]\n[ x o _ ]\n[ _ _ _ ]\n"
42
+
"My turn:\n[ x _ _ ]\n[ x o _ ]\n[ o _ _ ]\n"
43
+
"Your turn! Enter a coordinate or type help."),
44
+
after_1_3= ("[ x _ x ]\n[ x o _ ]\n[ o _ _ ]\n"
45
+
"My turn:\n[ x o x ]\n[ x o _ ]\n[ o _ _ ]\n"
46
+
"Your turn! Enter a coordinate or type help."),
47
+
after_3_2= ("[ x o x ]\n[ x o _ ]\n[ o x _ ]\n"
48
+
"My turn:\n[ x o x ]\n[ x o o ]\n[ o x _ ]\n"
49
+
"Your turn! Enter a coordinate or type help."),
50
+
)
34
51
35
52
expected_send_message= [
36
-
("", didnt_understand_txt),
37
-
("help", help_txt),
38
-
("quit", didnt_understand_txt), # Quit not understood when no game
39
-
("new", new_game_txt),
40
-
("quit", "You've successfully quit the game."), # If have state
41
-
("quit", didnt_understand_txt), # Quit not understood when no game
53
+
# Empty message
54
+
("", msg['didnt_understand']),
55
+
# Non-command
56
+
("adboh", msg['didnt_understand']),
57
+
# Help command
58
+
("help", msg['help']),
59
+
# Command: quit not understood with no game
60
+
("quit", msg['didnt_understand']),
61
+
# Can quit if new game and have state
62
+
("new", msg['new_game']),
63
+
("quit", msg['successful_quit']),
64
+
# Quit not understood when no game FIXME improve response?
0 commit comments