forked from gunthercox/ChatterBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_logic_adapter_integration.py
59 lines (39 loc) · 1.59 KB
/
test_logic_adapter_integration.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
54
55
56
57
58
59
from tests_django.base_case import ChatterBotTestCase
from chatterbot.conversation import Statement
class LogicIntegrationTestCase(ChatterBotTestCase):
"""
Tests to make sure that logic adapters
function correctly when using Django.
"""
def setUp(self):
super().setUp()
self.chatbot.storage.create(text='Default statement')
def test_best_match(self):
from chatterbot.logic import BestMatch
adapter = BestMatch(self.chatbot)
statement1 = self.chatbot.storage.create(
text='Do you like programming?',
conversation='test'
)
self.chatbot.storage.create(
text='Yes',
in_response_to=statement1.text,
conversation='test'
)
response = adapter.process(statement1)
self.assertEqual(response.text, 'Yes')
self.assertEqual(response.confidence, 1)
def test_mathematical_evaluation(self):
from chatterbot.logic import MathematicalEvaluation
adapter = MathematicalEvaluation(self.chatbot)
statement = Statement(text='What is 6 + 6?')
response = adapter.process(statement)
self.assertEqual(response.text, '6 + 6 = 12')
self.assertEqual(response.confidence, 1)
def test_time(self):
from chatterbot.logic import TimeLogicAdapter
adapter = TimeLogicAdapter(self.chatbot)
statement = Statement(text='What time is it?')
response = adapter.process(statement)
self.assertIn('The current time is', response.text)
self.assertEqual(response.confidence, 1)