Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: python -m pip install --upgrade pip pylint

- name: Run Pylint
run: pylint --rcfile=tests/.pylintrc $(find tests -name "*.py") || true
run: pylint --rcfile=tests/.pylintrc $(find tests -name "*.py")



Expand Down
16 changes: 8 additions & 8 deletions endpoints/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def lambda_handler(event, context):
Return doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
"""
PARAMETER_NAME = "searchTerm"

# These headers are always included to fix the CORS Issues
response = {
'headers': {
Expand All @@ -37,15 +37,15 @@ def lambda_handler(event, context):
response["statusCode"] = 400
response['body'] = {"error": f"Bad request: Missing query parameter '{PARAMETER_NAME}'"}
return response

if event['headers'] == None:
response["statusCode"] = 400
response['body'] = {"error": "Bad request: missing header"}
return response

query_parameters = event['queryStringParameters']
header = event['headers']

try:
session_id = header["Session-Id"]
except:
Expand All @@ -54,21 +54,21 @@ def lambda_handler(event, context):
"searchTerm": query_parameters["searchTerm"],
"pageNumber": query_parameters["pageNumber"],
"refreshResults": query_parameters["refreshResults"],
"sessionID": session_id,
"sessionID": session_id,
"sortParams": query_parameters["sortParams"],
"filterParams": query_parameters["filterParams"]
}

try:
response_body = search(input_json)

except Exception as e:
print(f"Exception in database query: {e}")
response["statusCode"] = 500
response['body'] = {"error": "Internal Server Error"}
return response



response["statusCode"] = 200
response['body'] = json.dumps(response_body)
Expand Down
4 changes: 2 additions & 2 deletions tests/handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def test_lambda_happy_path(mock_database):
"matchQuality": ".2"
}
])

event = { 'queryStringParameters': {'name': 'default'} }
context = {}

response = lambda_handler(event, context)
validate_200_response(response)

Expand Down
Loading