mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
more tests
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import json
|
||||
from unittest import mock
|
||||
from unittest.mock import ANY, Mock
|
||||
|
||||
import botocore
|
||||
import pytest
|
||||
|
||||
from app import aws_ses_client
|
||||
from app import AwsSesStubClient, aws_ses_client
|
||||
from app.clients.email import EmailClientNonRetryableException
|
||||
from app.clients.email.aws_ses import (
|
||||
AwsSesClientException,
|
||||
@@ -176,3 +178,27 @@ def test_send_email_raises_other_errs_as_AwsSesClientException(mocker):
|
||||
)
|
||||
|
||||
assert 'some error message from amazon' in str(excinfo.value)
|
||||
|
||||
|
||||
@mock.patch('app.clients.email.aws_ses_stub.request')
|
||||
def test_send_email_stub(mock_request):
|
||||
mock_request.return_value = FakeResponse()
|
||||
stub = AwsSesStubClient()
|
||||
stub.init_app("fake")
|
||||
answer = stub.send_email(
|
||||
'fake@fake.gov',
|
||||
'recipient@wherever.com',
|
||||
'TestTest',
|
||||
'TestBody')
|
||||
print(answer)
|
||||
assert answer == 'SomeId'
|
||||
|
||||
|
||||
class FakeResponse:
|
||||
def __init__(self):
|
||||
|
||||
t = {"MessageId": "SomeId"}
|
||||
self.text = json.dumps(t)
|
||||
|
||||
def raise_for_status(self):
|
||||
print("raised for status")
|
||||
|
||||
@@ -58,3 +58,14 @@ def test_should_raise_for_status(perf_client):
|
||||
with pytest.raises(requests.HTTPError), requests_mock.Mocker() as request_mock:
|
||||
request_mock.post('https://performance-platform-url/foo', json={}, status_code=403)
|
||||
perf_client.send_stats_to_performance_platform({'dataType': 'foo'})
|
||||
|
||||
|
||||
def generate_payload_id(payload, param):
|
||||
pass
|
||||
|
||||
|
||||
def test_generate_payload_id():
|
||||
payload = {'_timestamp': '2023-01-01 00:00:00', 'service': 'my_service', 'group_name': 'group_name',
|
||||
'dataType': 'dataType', 'period': 'period'}
|
||||
result = PerformancePlatformClient.generate_payload_id(payload, "group_name")
|
||||
assert result == 'MjAyMy0wMS0wMSAwMDowMDowMG15X3NlcnZpY2Vncm91cF9uYW1lZGF0YVR5cGVwZXJpb2Q='
|
||||
|
||||
Reference in New Issue
Block a user