File tree 2 files changed +22
-1
lines changed
aws_lambda_powertools/utilities/parser/models 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class APIGatewayEventRequestContext(BaseModel):
68
68
routeKey : Optional [str ]
69
69
operationName : Optional [str ]
70
70
71
- @root_validator ()
71
+ @root_validator
72
72
def check_message_id (cls , values ):
73
73
message_id , event_type = values .get ("messageId" ), values .get ("eventType" )
74
74
if message_id is not None and event_type != "MESSAGE" :
Original file line number Diff line number Diff line change @@ -108,7 +108,27 @@ def test_apigw_event():
108
108
def test_apigw_event_with_invalid_websocket_request ():
109
109
# GIVEN an event with an eventType != MESSAGE and has a messageId
110
110
event = {
111
+ "resource" : "/" ,
112
+ "path" : "/" ,
113
+ "httpMethod" : "GET" ,
114
+ "headers" : {},
115
+ "multiValueHeaders" : {},
116
+ "isBase64Encoded" : False ,
117
+ "body" : "Foo!" ,
111
118
"requestContext" : {
119
+ "accountId" : "1234" ,
120
+ "apiId" : "myApi" ,
121
+ "httpMethod" : "GET" ,
122
+ "identity" : {
123
+ "sourceIp" : "127.0.0.1" ,
124
+ },
125
+ "path" : "/" ,
126
+ "protocol" : "Https" ,
127
+ "requestId" : "1234" ,
128
+ "requestTime" : "2018-09-07T16:20:46Z" ,
129
+ "requestTimeEpoch" : 1536992496000 ,
130
+ "resourcePath" : "/" ,
131
+ "stage" : "test" ,
112
132
"eventType" : "DISCONNECT" ,
113
133
"messageId" : "messageId" ,
114
134
},
@@ -119,4 +139,5 @@ def test_apigw_event_with_invalid_websocket_request():
119
139
handle_apigw_event (event , LambdaContext ())
120
140
121
141
# THEN raise TypeError for invalid event
142
+ assert len (err .value .errors ()) == 1
122
143
assert "messageId is available only when the `eventType` is `MESSAGE`" in str (err .value )
You can’t perform that action at this time.
0 commit comments