This repository was archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathacceptance.py
77 lines (70 loc) · 2.11 KB
/
acceptance.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import os
import json
import pytest
import boto3
SERVICE_PREFIX = 'epsagon-acceptance-{}-{}'.format(
os.environ.get('TRAVIS_BUILD_NUMBER', ''),
os.environ.get('runtimeName', '')
)
def invoke(name, payload):
"""
invokes a lambda
:param name: the name of the lambda to invoke
:param payload: the payload
:return: the response
"""
lambda_client = boto3.client('lambda', region_name='us-east-1')
return lambda_client.invoke(
FunctionName='{}-{}'.format(SERVICE_PREFIX, name),
InvocationType='RequestResponse',
Payload=payload
)
class TestLambdaWrapper:
@pytest.mark.parametrize("input", [
'',
'{afwe',
[],
[1, 2, 3],
{},
{'test': 'test'},
{'test': 'test', 'more': [1, 2, '3']},
])
def test_sanity_valid_input(self, input):
response = invoke('sanity', json.dumps(input))
assert response['StatusCode'] == 200
content = json.loads(response['Payload'].read())
assert content['statusCode'] == 200
body = json.loads(content['body'])
assert body['input'] == input
@pytest.mark.parametrize("input", [
'',
'{afwe',
[],
[1, 2, 3],
{},
{'test': 'test'},
{'test': 'test', 'more': [1, 2, '3']},
])
def test_labels(self, input):
response = invoke('labels', json.dumps(input))
assert response['StatusCode'] == 200
content = json.loads(response['Payload'].read())
assert content['statusCode'] == 200
body = json.loads(content['body'])
assert body['input'] == input
@pytest.mark.parametrize("input", [
'',
'{afwe',
[],
[1, 2, 3],
{},
{'test': 'test'},
{'test': 'test', 'more': [1, 2, '3']},
])
def test_logging(self, input):
response = invoke('logging', json.dumps(input))
assert response['StatusCode'] == 200
content = json.loads(response['Payload'].read())
assert content['statusCode'] == 200
body = json.loads(content['body'])
assert body['input'] == input