diff --git a/zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json b/zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json new file mode 100644 index 0000000..0b19a04 --- /dev/null +++ b/zulip_bots/zulip_bots/bots/yoda/fixtures/test_2.json @@ -0,0 +1,14 @@ +{ + "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" + } +} diff --git a/zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json b/zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json new file mode 100644 index 0000000..fd1c74f --- /dev/null +++ b/zulip_bots/zulip_bots/bots/yoda/fixtures/test_only_numbers.json @@ -0,0 +1,14 @@ +{ + "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" + } +} diff --git a/zulip_bots/zulip_bots/bots/yoda/test_yoda.py b/zulip_bots/zulip_bots/bots/yoda/test_yoda.py index 9f04dea..f0cbe62 100644 --- a/zulip_bots/zulip_bots/bots/yoda/test_yoda.py +++ b/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' + )