bots: Simplify define bot test.
This commit is contained in:
parent
9b67e94ba8
commit
a85c7a0705
|
@ -16,37 +16,25 @@ if os.path.exists(os.path.join(our_dir, '..')):
|
||||||
from bots_test_lib import BotTestCase
|
from bots_test_lib import BotTestCase
|
||||||
|
|
||||||
class TestDefineBot(TestCase):
|
class TestDefineBot(TestCase):
|
||||||
|
def setUp(self):
|
||||||
# Messages to be sent to bot for testing.
|
# Messages to be sent to bot for testing.
|
||||||
# Eventually more test messages can be added.
|
self.request_messages = [
|
||||||
def request_messages(self):
|
{'content': "foo", 'type': "private", 'sender_email': "foo"},
|
||||||
# type: None -> List[Dict[str, str]]
|
{'content': "cat", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"},
|
||||||
messages = []
|
]
|
||||||
message1 = {'content': "foo", 'type': "private", 'sender_email': "foo"}
|
|
||||||
message2 = {'content': "cat", 'type': "stream", 'display_recipient': "foo", 'subject': "foo"}
|
|
||||||
messages.append(message1)
|
|
||||||
messages.append(message2)
|
|
||||||
return messages
|
|
||||||
|
|
||||||
# Reply messages from the test bot.
|
# Reply messages from the test bot.
|
||||||
# Each reply message corresponding to each request message.
|
self.bot_response_messages = [
|
||||||
def bot_response_messages(self):
|
"**foo**:\nDefinition not available.",
|
||||||
# type: None -> List[str]
|
("**cat**:\n\n* (**noun**) a small domesticated carnivorous mammal "
|
||||||
messages = []
|
|
||||||
message1 = "**foo**:\nDefinition not available."
|
|
||||||
message2 = ("**cat**:\n\n* (**noun**) a small domesticated carnivorous mammal "
|
|
||||||
"with soft fur, a short snout, and retractile claws. It is widely "
|
"with soft fur, a short snout, and retractile claws. It is widely "
|
||||||
"kept as a pet or for catching mice, and many breeds have been "
|
"kept as a pet or for catching mice, and many breeds have been "
|
||||||
"developed.\n their pet cat\n\n")
|
"developed.\n their pet cat\n\n"),
|
||||||
messages.append(message1)
|
]
|
||||||
messages.append(message2)
|
|
||||||
return messages
|
|
||||||
|
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
# type: None -> None
|
# type: None -> None
|
||||||
# Edit bot_module to test different bots, the below code can be looped for all the bots.
|
# Edit bot_module to test different bots, the below code can be looped for all the bots.
|
||||||
bot_module = os.path.join(our_dir, "define.py")
|
bot_module = os.path.join(our_dir, "define.py")
|
||||||
messages = self.request_messages()
|
|
||||||
bot_response = self.bot_response_messages()
|
|
||||||
test_case = BotTestCase()
|
test_case = BotTestCase()
|
||||||
test_case.bot_test(messages=messages, bot_module=bot_module, bot_response=bot_response)
|
test_case.bot_test(messages=self.request_messages, bot_module=bot_module,
|
||||||
|
bot_response=self.bot_response_messages)
|
||||||
|
|
Loading…
Reference in a new issue