Skip to content

Commit 7b896be

Browse files
author
Michael Brewer
committed
chore: recommended updates
1 parent 0e01247 commit 7b896be

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

aws_lambda_powertools/utilities/parser/models/apigw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class APIGatewayEventRequestContext(BaseModel):
6868
routeKey: Optional[str]
6969
operationName: Optional[str]
7070

71-
@root_validator()
71+
@root_validator
7272
def check_message_id(cls, values):
7373
message_id, event_type = values.get("messageId"), values.get("eventType")
7474
if message_id is not None and event_type != "MESSAGE":

tests/functional/parser/test_apigw.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,27 @@ def test_apigw_event():
108108
def test_apigw_event_with_invalid_websocket_request():
109109
# GIVEN an event with an eventType != MESSAGE and has a messageId
110110
event = {
111+
"resource": "/",
112+
"path": "/",
113+
"httpMethod": "GET",
114+
"headers": {},
115+
"multiValueHeaders": {},
116+
"isBase64Encoded": False,
117+
"body": "Foo!",
111118
"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",
112132
"eventType": "DISCONNECT",
113133
"messageId": "messageId",
114134
},
@@ -119,4 +139,5 @@ def test_apigw_event_with_invalid_websocket_request():
119139
handle_apigw_event(event, LambdaContext())
120140

121141
# THEN raise TypeError for invalid event
142+
assert len(err.value.errors()) == 1
122143
assert "messageId is available only when the `eventType` is `MESSAGE`" in str(err.value)

0 commit comments

Comments
 (0)