zulip_bots: Reify StateHandler testing.

This simplifies testing stateful bots by integrating the StateHandler
into the test library. As a side-effect, the mock bot handler gets
reused during a test, making the tests more realistic. The
StateHandler now keeps its state during a call to check_expected_responses,
forcing some stateful tests to be more verbose and explicit.
This commit is contained in:
derAnfaenger 2017-10-23 20:37:39 +02:00
parent e331426c64
commit 8179b30873
4 changed files with 60 additions and 68 deletions

View file

@ -86,11 +86,11 @@ class TestTictactoeBot(BotTestCase):
("1,1", msg['after_1_1']),
("2, 1", msg['after_2_1']),
("(1,3)", msg['after_1_3']),
("quit", msg['successful_quit']),
# Can't test 'after_3_2' as it's random!
]
for m in messages:
state = StateHandler()
for (mesg, resp) in expected_send_message:
self.assert_bot_response(dict(m, content=mesg),
dict(private_response, content=resp),
'send_message', state)
'send_message')