Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryStringParameters set to None when there are no GET parameters #5893

Merged
merged 5 commits into from Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions localstack/services/awslambda/lambda_api.py
Expand Up @@ -615,8 +615,8 @@ def construct_invocation_event(
"body": data,
"isBase64Encoded": is_base64_encoded,
"httpMethod": method,
"queryStringParameters": query_string_params,
"multiValueQueryStringParameters": multi_value_dict_for_list(query_string_params),
"queryStringParameters": query_string_params or None,
"multiValueQueryStringParameters": multi_value_dict_for_list(query_string_params) or None,
}


Expand Down
90 changes: 90 additions & 0 deletions tests/unit/services/awslambda/test_lambda_api.py
@@ -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"]