|
1 | 1 | import pytest |
2 | 2 | import boto3 |
3 | 3 | import requests |
| 4 | +import localstack.sdk.aws |
4 | 5 | import json |
5 | 6 | import time |
6 | 7 |
|
@@ -207,27 +208,25 @@ def calculate_user_score(user_answers): |
207 | 208 |
|
208 | 209 | print(f"Verified submission for {submission['Username']} with Score: {actual_score}") |
209 | 210 |
|
210 | | - ses_endpoint = "http://localhost:4566/_aws/ses" |
211 | | - ses_response = requests.get(ses_endpoint) |
212 | | - assert ses_response.status_code == 200 |
213 | | - ses_data = ses_response.json() |
214 | | - |
215 | | - messages = ses_data.get('messages', []) |
| 211 | + client = localstack.sdk.aws.AWSClient() |
216 | 212 | sender_email = "[email protected]" |
217 | | - email_found = False |
| 213 | + messages = client.get_ses_messages(email_filter=sender_email) |
218 | 214 |
|
| 215 | + email_found = False |
219 | 216 | for message in messages: |
220 | | - if message.get('Source') == sender_email: |
| 217 | + if message.source == sender_email: |
221 | 218 | email_found = True |
222 | | - assert 'Id' in message |
223 | | - assert 'Region' in message |
224 | | - assert 'Timestamp' in message |
225 | | - assert 'Destination' in message |
226 | | - assert 'Subject' in message |
227 | | - assert 'Body' in message |
228 | | - |
229 | | - body = message['Body'] |
230 | | - assert 'html_part' in body |
231 | | - html_content = body['html_part'] |
| 219 | + assert hasattr(message, 'id') |
| 220 | + assert hasattr(message, 'region') |
| 221 | + assert hasattr(message, 'timestamp') |
| 222 | + assert hasattr(message, 'destination') |
| 223 | + assert hasattr(message, 'subject') |
| 224 | + assert hasattr(message, 'body') |
| 225 | + |
| 226 | + body = message.body |
| 227 | + assert hasattr(body, 'html_part') |
| 228 | + html_content = body.html_part |
| 229 | + |
| 230 | + print(f"Email content: {html_content}") |
232 | 231 |
|
233 | 232 | assert email_found, f"No email found sent from {sender_email}" |
0 commit comments