forked from aloverso/loanbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
53 lines (45 loc) · 1.75 KB
/
tests.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!flask/bin/python
import unittest
import conversation_handler
import fake_database_client
import messenger_client
from server import app
# messenger_client = messengerClient.MessengerClient()
database_client = fake_database_client.FakeDatabaseClient()
conversation_handler = conversation_handler.ConversationHandler(database_client)
class TestCase(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
self.app = app.test_client()
def tearDown(self):
pass
def test_find_tools_in_message(self):
test_message_1 = "I would like to borrow the drill and the screwdriver, please!"
test_message_2 = "I want to take out a drill"
test_message_3 = "I think it's cool that the library has tools"
self.assertEqual(
conversation_handler.find_tools_in_message(test_message_1), [{
"_id": {
"$oid": "58e5528dbf24551abe30660f"
},
"current_user": {
"$oid": "58ebabe3638acc000b2e2429"
},
"name": "screwdriver",
"alternate_names": [],
"current_due_date": 1492100080
}, {
"_id": {
"$oid": "58e5528dbf24551abe306610"
},
"current_due_date": 1491424505,
"name": "drill",
"alternate_names": [],
"current_user": {
"$oid": "58dfe761db78bb000bf7c88b"
}
}])
self.assertEqual(len(conversation_handler.find_tools_in_message(test_message_2)), 1)
self.assertEqual(len(conversation_handler.find_tools_in_message(test_message_3)), 0)
if __name__ == '__main__':
unittest.main()