forked from codediodeio/lex-chatbot-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_test.py
43 lines (37 loc) · 1.04 KB
/
unit_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
37
38
39
40
41
42
43
import unittest
import bot
test_input = {
"currentIntent": {
"slots": {
"buyer": "Joe",
"seller": "John",
"buyerAddress": None,
},
"name": "BillOfSale",
"confirmationStatus": "None"
},
"bot": {
"alias": "$LATEST",
"version": "$LATEST",
"name": "TestBot"
},
"userId": "uid",
# "invocationSource": "ElicitSlotCodeHook",
"invocationSource": "FulfillmentCodeHook",
"outputDialogMode": "Text",
"messageVersion": "1.0",
"inputTranscript": "user message",
"sessionAttributes": {
}
}
class LambdaTestCase(unittest.TestCase):
def test_not_none(self):
"""Response is not None"""
res = bot.lambda_handler(test_input)
self.assertIsNotNone(res)
def test_fulfillment(self):
"""Response is fulfilled"""
res = bot.lambda_handler(test_input)
self.assertEqual(res['dialogAction']['fulfillmentState'], 'Fulfilled')
if __name__ == '__main__':
unittest.main()