generated from lambda-feedback/Evaluation-Function-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_test.py
61 lines (45 loc) · 1.78 KB
/
index_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import unittest
try:
from .index import handler
except ImportError:
from index import handler
class TestChatIndexFunction(unittest.TestCase):
"""
TestCase Class used to test the algorithm.
---
Tests are used here to check that the algorithm written
is working as it should.
It's best practise to write these tests first to get a
kind of 'specification' for how your algorithm should
work, and you should run these tests before committing
your code to AWS.
Read the docs on how to use unittest here:
https://docs.python.org/3/library/unittest.html
Use module() to check your algorithm works
as it should.
"""
# TODO: update the test cases
def test_missing_argument(self):
arguments = ["message", "params"]
for arg in arguments:
event = {
"message": "Hello, World",
"params": {"conversation_id": "1234Test", "conversation_history": [{"type": "user", "content": "Hello, World"}]}
}
event.pop(arg)
result = handler(event, None)
self.assertEqual(result.get("statusCode"), 400)
def test_correct_arguments(self):
event = {
"message": "Hello, World",
"params": {"conversation_id": "1234Test", "conversation_history": [{"type": "user", "content": "Hello, World"}]}
}
result = handler(event, None)
self.assertEqual(result.get("statusCode"), 200)
def test_correct_response(self):
event = {
"message": "Hello, World",
"params": {"conversation_id": "1234Test", "conversation_history": [{"type": "user", "content": "Hello, World"}]}
}
result = handler(event, None)
self.assertEqual(result.get("statusCode"), 200)