mostr-zulip-bot/zulip_bots/zulip_bots/bots/followup/test_followup.py
Steve Howell fd069dff82 lint: Require python3 shebangs.
This commit was originally from @fredfishgames, but it
needed a big rebase due to use letting it sit too long.
Also, we decided not to have shebangs at the top of test
files.
2017-12-12 07:14:16 -06:00

60 lines
1.9 KiB
Python
Executable file

from __future__ import absolute_import
from __future__ import print_function
from zulip_bots.test_lib import (
StubBotHandler,
StubBotTestCase,
get_bot_message_handler,
)
from typing import Any
class TestFollowUpBot(StubBotTestCase):
bot_name = "followup"
def test_followup_stream(self) -> None:
message = dict(
content='feed the cat',
type='stream',
sender_email='foo@example.com',
)
with self.mock_config_info({'stream': 'followup'}):
response = self.get_response(message)
self.assertEqual(response['content'], 'from foo@example.com: feed the cat')
self.assertEqual(response['to'], 'followup')
def test_different_stream(self) -> None:
message = dict(
content='feed the cat',
type='stream',
sender_email='foo@example.com',
)
with self.mock_config_info({'stream': 'issue'}):
response = self.get_response(message)
self.assertEqual(response['content'], 'from foo@example.com: feed the cat')
self.assertEqual(response['to'], 'issue')
def test_bot_responds_to_empty_message(self) -> None:
bot_response = 'Please specify the message you want to send to followup stream after @mention-bot'
with self.mock_config_info({'stream': 'followup'}):
self.verify_reply('', bot_response)
def test_help_text(self) -> None:
request = 'help'
bot_response = '''
This plugin will allow users to flag messages
as being follow-up items. Users should preface
messages with "@mention-bot".
Before running this, make sure to create a stream
called "followup" that your API user can send to.
'''
with self.mock_config_info({'stream': 'followup'}):
self.verify_reply(request, bot_response)