-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add localstack sdk ses workflow for tests (#11)
- Loading branch information
1 parent
267ade9
commit 633f72a
Showing
1 changed file
with
17 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import pytest | ||
import boto3 | ||
import requests | ||
import localstack.sdk.aws | ||
import json | ||
import time | ||
|
||
|
@@ -207,27 +208,25 @@ def calculate_user_score(user_answers): | |
|
||
print(f"Verified submission for {submission['Username']} with Score: {actual_score}") | ||
|
||
ses_endpoint = "http://localhost:4566/_aws/ses" | ||
ses_response = requests.get(ses_endpoint) | ||
assert ses_response.status_code == 200 | ||
ses_data = ses_response.json() | ||
|
||
messages = ses_data.get('messages', []) | ||
client = localstack.sdk.aws.AWSClient() | ||
sender_email = "[email protected]" | ||
email_found = False | ||
messages = client.get_ses_messages(email_filter=sender_email) | ||
|
||
email_found = False | ||
for message in messages: | ||
if message.get('Source') == sender_email: | ||
if message.source == sender_email: | ||
email_found = True | ||
assert 'Id' in message | ||
assert 'Region' in message | ||
assert 'Timestamp' in message | ||
assert 'Destination' in message | ||
assert 'Subject' in message | ||
assert 'Body' in message | ||
|
||
body = message['Body'] | ||
assert 'html_part' in body | ||
html_content = body['html_part'] | ||
assert hasattr(message, 'id') | ||
assert hasattr(message, 'region') | ||
assert hasattr(message, 'timestamp') | ||
assert hasattr(message, 'destination') | ||
assert hasattr(message, 'subject') | ||
assert hasattr(message, 'body') | ||
|
||
body = message.body | ||
assert hasattr(body, 'html_part') | ||
html_content = body.html_part | ||
|
||
print(f"Email content: {html_content}") | ||
|
||
assert email_found, f"No email found sent from {sender_email}" |