mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
notify-243 remove statsd
This commit is contained in:
@@ -4,7 +4,7 @@ from unittest.mock import ANY
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app import encryption, statsd_client
|
||||
from app import encryption
|
||||
from app.celery.process_ses_receipts_tasks import (
|
||||
process_ses_results,
|
||||
remove_emails_from_bounce,
|
||||
@@ -141,8 +141,6 @@ def test_ses_callback_should_update_notification_status(
|
||||
sample_email_template,
|
||||
mocker):
|
||||
with freeze_time('2001-01-01T12:00:00'):
|
||||
mocker.patch('app.statsd_client.incr')
|
||||
mocker.patch('app.statsd_client.timing_with_dates')
|
||||
send_mock = mocker.patch(
|
||||
'app.celery.service_callback_tasks.send_delivery_status_to_service.apply_async'
|
||||
)
|
||||
@@ -161,10 +159,6 @@ def test_ses_callback_should_update_notification_status(
|
||||
assert get_notification_by_id(notification.id).status == 'sending'
|
||||
assert process_ses_results(ses_notification_callback(reference='ref'))
|
||||
assert get_notification_by_id(notification.id).status == 'delivered'
|
||||
statsd_client.timing_with_dates.assert_any_call(
|
||||
"callback.ses.elapsed-time", datetime.utcnow(), notification.sent_at
|
||||
)
|
||||
statsd_client.incr.assert_any_call("callback.ses.delivered")
|
||||
send_mock.assert_called_once_with([str(notification.id), ANY], queue="service-callbacks")
|
||||
# assert second arg is an encrypted string
|
||||
assert isinstance(send_mock.call_args.args[0][1], str)
|
||||
|
||||
@@ -57,7 +57,6 @@ def test_should_be_none_if_unrecognised_status_code():
|
||||
], ids=['empty', 'single_email', 'punycode'])
|
||||
def test_send_email_handles_reply_to_address(notify_api, mocker, reply_to_address, expected_value):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
|
||||
with notify_api.app_context():
|
||||
aws_ses_client.send_email(
|
||||
@@ -78,7 +77,6 @@ def test_send_email_handles_reply_to_address(notify_api, mocker, reply_to_addres
|
||||
|
||||
def test_send_email_handles_punycode_to_address(notify_api, mocker):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
|
||||
with notify_api.app_context():
|
||||
aws_ses_client.send_email(
|
||||
@@ -98,7 +96,6 @@ def test_send_email_handles_punycode_to_address(notify_api, mocker):
|
||||
|
||||
def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetryableException(mocker):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
error_response = {
|
||||
'Error': {
|
||||
'Code': 'InvalidParameterValue',
|
||||
@@ -107,7 +104,6 @@ def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetrya
|
||||
}
|
||||
}
|
||||
boto_mock.send_email.side_effect = botocore.exceptions.ClientError(error_response, 'opname')
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
|
||||
with pytest.raises(EmailClientNonRetryableException) as excinfo:
|
||||
aws_ses_client.send_email(
|
||||
@@ -122,7 +118,6 @@ def test_send_email_raises_invalid_parameter_value_error_as_EmailClientNonRetrya
|
||||
|
||||
def test_send_email_raises_send_rate_throttling_as_AwsSesClientThrottlingSendRateException(mocker):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
error_response = {
|
||||
'Error': {
|
||||
'Code': 'Throttling',
|
||||
@@ -143,7 +138,6 @@ def test_send_email_raises_send_rate_throttling_as_AwsSesClientThrottlingSendRat
|
||||
|
||||
def test_send_email_does_not_raise_AwsSesClientThrottlingSendRateException_if_non_send_rate_throttling(mocker):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
error_response = {
|
||||
'Error': {
|
||||
'Code': 'Throttling',
|
||||
@@ -164,7 +158,6 @@ def test_send_email_does_not_raise_AwsSesClientThrottlingSendRateException_if_no
|
||||
|
||||
def test_send_email_raises_other_errs_as_AwsSesClientException(mocker):
|
||||
boto_mock = mocker.patch.object(aws_ses_client, '_client', create=True)
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
error_response = {
|
||||
'Error': {
|
||||
'Code': 'ServiceUnavailable',
|
||||
@@ -173,7 +166,6 @@ def test_send_email_raises_other_errs_as_AwsSesClientException(mocker):
|
||||
}
|
||||
}
|
||||
boto_mock.send_email.side_effect = botocore.exceptions.ClientError(error_response, 'opname')
|
||||
mocker.patch.object(aws_ses_client, 'statsd_client', create=True)
|
||||
|
||||
with pytest.raises(AwsSesClientException) as excinfo:
|
||||
aws_ses_client.send_email(
|
||||
|
||||
@@ -5,7 +5,6 @@ from app import aws_sns_client
|
||||
|
||||
def test_send_sms_successful_returns_aws_sns_response(notify_api, mocker):
|
||||
boto_mock = mocker.patch.object(aws_sns_client, '_client', create=True)
|
||||
mocker.patch.object(aws_sns_client, 'statsd_client', create=True)
|
||||
to = "6135555555"
|
||||
content = reference = 'foo'
|
||||
with notify_api.app_context():
|
||||
@@ -22,7 +21,6 @@ def test_send_sms_successful_returns_aws_sns_response(notify_api, mocker):
|
||||
|
||||
def test_send_sms_returns_raises_error_if_there_is_no_valid_number_is_found(notify_api, mocker):
|
||||
mocker.patch.object(aws_sns_client, '_client', create=True)
|
||||
mocker.patch.object(aws_sns_client, 'statsd_client', create=True)
|
||||
to = ""
|
||||
content = reference = 'foo'
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from app import statsd_client
|
||||
from app.clients.sms import SmsClient, SmsClientResponseException
|
||||
|
||||
|
||||
@@ -12,7 +11,7 @@ def fake_client(notify_api):
|
||||
return 'fake'
|
||||
|
||||
fake_client = FakeSmsClient()
|
||||
fake_client.init_app(notify_api, statsd_client)
|
||||
# fake_client.init_app(notify_api)
|
||||
return fake_client
|
||||
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ def app_for_test():
|
||||
app = flask.Flask(__name__)
|
||||
app.config['TESTING'] = True
|
||||
init_app(app)
|
||||
from app import statsd_client
|
||||
statsd_client.init_app(app)
|
||||
|
||||
from app.v2.errors import register_errors
|
||||
blue = Blueprint("v2_under_test", __name__, url_prefix='/v2/under_test')
|
||||
|
||||
Reference in New Issue
Block a user