-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
5 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
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,76 @@ | ||
import json | ||
import boto3 | ||
import pytest | ||
from test_helpers.terraform import read_terraform_output | ||
|
||
|
||
STATE_MACHINE_INPUT_WITHOUT_ERROR_MESSAGE = [ | ||
{ | ||
"ETag": '"9b41ef67651c18488a8b08bb67c75699"', | ||
"ServerSideEncryption": "AES256", | ||
"VersionId": "VHBhCwygSeYxgEEecU7N.meZl3uKDoaA", | ||
}, | ||
{ | ||
"stage_name": "load", | ||
"processed_records": 0, | ||
"unprocessed_records": 0, | ||
"error_message": None, | ||
}, | ||
] | ||
|
||
STATE_MACHINE_INPUT_WITH_ERROR_MESSAGE = [ | ||
{ | ||
"ETag": '"9b41ef67651c18488a8b08bb67c75699"', | ||
"ServerSideEncryption": "AES256", | ||
"VersionId": "VHBhCwygSeYxgEEecU7N.meZl3uKDoaA", | ||
}, | ||
{ | ||
"stage_name": "load", | ||
"processed_records": 0, | ||
"unprocessed_records": 0, | ||
"error_message": "oops", | ||
}, | ||
] | ||
|
||
|
||
def test_notify_lambda_with_state_machine_input_without_error_message(): | ||
from etl.notify import notify | ||
|
||
assert notify.handler(event=STATE_MACHINE_INPUT_WITHOUT_ERROR_MESSAGE) == "pass" | ||
|
||
|
||
def test_notify_lambda_with_state_machine_input_with_error_message(): | ||
from etl.notify import notify | ||
|
||
assert notify.handler(event=STATE_MACHINE_INPUT_WITH_ERROR_MESSAGE) == "fail" | ||
|
||
|
||
@pytest.mark.integration | ||
def test_notify_lambda_without_error_message(): | ||
notify_lambda_arn = read_terraform_output("sds_etl.value.notify_lambda_arn") | ||
|
||
lambda_client = boto3.client("lambda") | ||
response = lambda_client.invoke( | ||
FunctionName=notify_lambda_arn, | ||
Payload=json.dumps([{"message": "test"}]).encode(), | ||
) | ||
assert response["Payload"].read() == "pass" | ||
|
||
|
||
@pytest.mark.integration | ||
def test_notify_lambda_with_error_message(): | ||
notify_lambda_arn = read_terraform_output("sds_etl.value.notify_lambda_arn") | ||
|
||
lambda_client = boto3.client("lambda") | ||
response = lambda_client.invoke( | ||
FunctionName=notify_lambda_arn, | ||
Payload=json.dumps( | ||
[ | ||
{ | ||
"message": "test", | ||
"error_message": "this is an error", | ||
} | ||
] | ||
).encode(), | ||
) | ||
assert response["Payload"].read() == "fail" |
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