Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set queryStringParameters to None in API GW invocation event if no qu…
…ery params present (#5893)
- Loading branch information
1 parent
402a079
commit 4553d47
Showing
2 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from localstack.services.awslambda.lambda_api import construct_invocation_event | ||
|
||
|
||
class TestLambdaApi: | ||
def test_construct_invocation_event(self): | ||
tt = [ | ||
{ | ||
"method": "GET", | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"data": None, | ||
"query_string_params": None, | ||
"is_base64_encoded": False, | ||
"expected": { | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"multiValueHeaders": {}, | ||
"body": None, | ||
"isBase64Encoded": False, | ||
"httpMethod": "GET", | ||
"queryStringParameters": None, | ||
"multiValueQueryStringParameters": None, | ||
}, | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"data": None, | ||
"query_string_params": {}, | ||
"is_base64_encoded": False, | ||
"expected": { | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"multiValueHeaders": {}, | ||
"body": None, | ||
"isBase64Encoded": False, | ||
"httpMethod": "GET", | ||
"queryStringParameters": None, | ||
"multiValueQueryStringParameters": None, | ||
}, | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"data": None, | ||
"query_string_params": {"foo": "bar"}, | ||
"is_base64_encoded": False, | ||
"expected": { | ||
"path": "http://localhost.localstack.cloud", | ||
"headers": {}, | ||
"multiValueHeaders": {}, | ||
"body": None, | ||
"isBase64Encoded": False, | ||
"httpMethod": "GET", | ||
"queryStringParameters": {"foo": "bar"}, | ||
"multiValueQueryStringParameters": {"foo": ("bar",)}, | ||
}, | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "http://localhost.localstack.cloud?baz=qux", | ||
"headers": {}, | ||
"data": None, | ||
"query_string_params": {"foo": "bar"}, | ||
"is_base64_encoded": False, | ||
"expected": { | ||
"path": "http://localhost.localstack.cloud?baz=qux", | ||
"headers": {}, | ||
"multiValueHeaders": {}, | ||
"body": None, | ||
"isBase64Encoded": False, | ||
"httpMethod": "GET", | ||
"queryStringParameters": {"foo": "bar"}, | ||
"multiValueQueryStringParameters": {"foo": ("bar",)}, | ||
}, | ||
}, | ||
] | ||
|
||
for t in tt: | ||
result = construct_invocation_event( | ||
t["method"], | ||
t["path"], | ||
t["headers"], | ||
t["data"], | ||
t["query_string_params"], | ||
t["is_base64_encoded"], | ||
) | ||
assert result == t["expected"] |