bots: Add some more test fixtures for yoda bot.
ADD
zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json
+{
+ "request": {
+ "api_url": "https://yoda.p.mashape.com/yoda?sentence=you+still+have+much+to+learn",
+ "headers": {
+ "X-Mashape-Key": "12345678",
+ "Accept": "text/plain"
+ }
+ },
+ "response": {"text": "Much to learn, you still have."},
+ "response-headers": {
+ "status": 200,
+ "content-type": "text/html; charset=utf-8"
+ }
+}

ADD
zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json
+{
+ "request": {
+ "api_url": "https://yoda.p.mashape.com/yoda?sentence=23456",
+ "headers": {
+ "X-Mashape-Key": "12345678",
+ "Accept": "text/plain"
+ }
+ },
+ "response": {"text": "23456. Herh herh herh."},
+ "response-headers": {
+ "status": 200,
+ "content-type": "text/html; charset=utf-8"
+ }
+}

MODIFY
zulip_bots/zulip_bots/bots/yoda/test_yoda.py
zulip_bots/zulip_bots/bots/yoda/test_yoda.py
@@ -11,6 +11,7 @@ class TestYodaBot(BotTestCase):
bot_name = "yoda"
def test_bot(self):
+
bot_response = "Learn how to speak like me someday, you will. Yes, hmmm."
with self.mock_config_info({'api_key': '12345678'}), \
@@ -21,3 +22,43 @@ class TestYodaBot(BotTestCase):
response = {'content': bot_response},
expected_method='send_reply'
)
+
+ bot_response = "Much to learn, you still have."
+
+ with self.mock_config_info({'api_key': '12345678'}), \
+ self.mock_http_conversation('test_2'):
+ self.initialize_bot()
+ self.assert_bot_response(
+ message = {'content': 'you still have much to learn'},
+ response = {'content': bot_response},
+ expected_method='send_reply'
+ )
+
+ bot_response = "23456. Herh herh herh."
+
+ with self.mock_config_info({'api_key': '12345678'}), \
+ self.mock_http_conversation('test_only_numbers'):
+ self.initialize_bot()
+ self.assert_bot_response(
+ message = {'content': '23456'},
+ response = {'content': bot_response},
+ expected_method='send_reply'
+ )
+
+ bot_response = '''
+ This bot allows users to translate a sentence into
+ 'Yoda speak'.
+ Users should preface messages with '@mention-bot'.
+
+ Before running this, make sure to get a Mashape Api token.
+ Instructions are in the 'readme.md' file.
+ Store it in the 'yoda.config' file.
+ The 'yoda.config' file should be located at '~/yoda.config'.
+ Example input:
+ @mention-bot You will learn how to speak like me someday.
+ '''
+ self.assert_bot_response(
+ message = {'content': 'help'},
+ response = {'content': bot_response},
+ expected_method='send_reply'
+ )

bots: Add some more test fixtures for yoda bot.