-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
36 lines (27 loc) · 1023 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import unittest
import bot
class MessageProcessing(unittest.TestCase):
def _message(self, text, response):
# Handle single strings
if type(response) != list:
response = [response]
message = bot.Message(text=text)
self.assertEqual(bot.process_message(message), response)
def _command(self, command, text, response):
self._message(bot.PREFIX + command + " " + text, response)
def test_empty(self):
self._message("This shouldn't trigger anything.", [])
def test_invalid_command(self):
self._command(
"this_is_not_a_real_command",
"some content",
"Command not found. Use !help to view a list of commands.",
)
def test_static(self):
for key in bot.static_commands:
self._command(key, "", bot.static_commands[key])
def test_morse(self):
self._command("morse", "SOS", "... --- ...")
if __name__ == "__main__":
unittest.main()