-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
55 lines (43 loc) · 1.12 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
54
55
from main import lambda_handler, InvalidDataException
def test_valid_params_lambda_handler():
event = {
"parameters": {
"data": [{"a": "b"}, {"c": "d"}]
}
}
response = lambda_handler(event, None)
assert response == {"a": "b", "c": "d"}
def test_collapse_root_dict():
event = {
"parameters": {
"data": [[{"a": "b"}], [{"c": "d"}]],
"collapse_root_list": True
}
}
response = lambda_handler(event, None)
assert response == {"a": "b", "c": "d"}
def _check_exc(data, exc_type):
matched = False
try:
lambda_handler(data, None)
except exc_type:
matched = True
assert matched, 'Exception was not triggered'
def test_mixed_root_dict():
_check_exc({
"parameters": {
"data": [[{"a": "b"}], {"c": "d"}],
"collapse_root_list": True
}
}, InvalidDataException)
def test_empty_parameters():
_check_exc({
"parameters": {
}
}, KeyError)
def test_null_data():
_check_exc({
"parameters": {
"data": None
}
}, TypeError)