-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathtest_base_path.py
103 lines (73 loc) · 2.43 KB
/
test_base_path.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
from aws_lambda_powertools.event_handler import (
ALBResolver,
APIGatewayHttpResolver,
APIGatewayRestResolver,
LambdaFunctionUrlResolver,
VPCLatticeResolver,
VPCLatticeV2Resolver,
)
from tests.functional.utils import load_event
def test_base_path_api_gateway_rest():
app = APIGatewayRestResolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("apiGatewayProxyEvent.json")
event["path"] = "/"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""
def test_base_path_api_gateway_http():
app = APIGatewayHttpResolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("apiGatewayProxyV2Event.json")
event["rawPath"] = "/"
event["requestContext"]["http"]["path"] = "/"
event["requestContext"]["http"]["method"] = "GET"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""
def test_base_path_alb():
app = ALBResolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("albEvent.json")
event["path"] = "/"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""
def test_base_path_lambda_function_url():
app = LambdaFunctionUrlResolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("lambdaFunctionUrlIAMEvent.json")
event["rawPath"] = "/"
event["requestContext"]["http"]["path"] = "/"
event["requestContext"]["http"]["method"] = "GET"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""
def test_vpc_lattice():
app = VPCLatticeResolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("vpcLatticeEvent.json")
event["raw_path"] = "/"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""
def test_vpc_latticev2():
app = VPCLatticeV2Resolver(enable_validation=True)
@app.get("/")
def handle():
return app._get_base_path()
event = load_event("vpcLatticeV2Event.json")
event["path"] = "/"
result = app(event, {})
assert result["statusCode"] == 200
assert result["body"] == ""