contrib_bots: Add check_expected_responses() test helper and use it.

This further simplifies the logic for testing a contrib_bots bot to
require very little code per test in the common case.
This commit is contained in:
neiljp 2017-05-29 14:14:11 -07:00 committed by Tim Abbott
parent 536ab436ed
commit 1991e0128b
8 changed files with 63 additions and 97 deletions

View file

@ -16,23 +16,11 @@ class TestEncryptBot(BotTestCase):
bot_name = "encrypt"
def test_bot(self):
self.assert_bot_output(
{'content': "Please encrypt this", 'type': "private", 'sender_email': "foo@gmail.com"},
"Encrypted/Decrypted text: Cyrnfr rapelcg guvf"
)
self.assert_bot_output(
{'content': "Let\'s Do It", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"},
"Encrypted/Decrypted text: Yrg\'f Qb Vg"
)
self.assert_bot_output(
{'content': "", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"},
"Encrypted/Decrypted text: "
)
self.assert_bot_output(
{'content': "me&mom together..!!", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"},
"Encrypted/Decrypted text: zr&zbz gbtrgure..!!"
)
self.assert_bot_output(
{'content': "foo bar", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"},
"Encrypted/Decrypted text: sbb one"
)
expected = {
"": "Encrypted/Decrypted text: ",
"Let\'s Do It": "Encrypted/Decrypted text: Yrg\'f Qb Vg",
"me&mom together..!!": "Encrypted/Decrypted text: zr&zbz gbtrgure..!!",
"foo bar": "Encrypted/Decrypted text: sbb one",
"Please encrypt this": "Encrypted/Decrypted text: Cyrnfr rapelcg guvf",
}
self.check_expected_responses(expected)