When someone complains about an email from the platform we get a callback from SES.

A new platform admin page Email complaints has been added to surface those complaints.
Eventually the complaints will be visible to the services so they can remove the email address from their mailing list.

Next thing to implement is "x email complaints" warning on the platform admin summary page.
This commit is contained in:
Rebecca Law
2018-06-06 15:22:48 +01:00
parent 217cf9abd4
commit 84445d154d
8 changed files with 108 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import datetime
import uuid
from unittest.mock import ANY
import pytest
@@ -637,3 +638,32 @@ def test_sum_service_usage_with_zeros(fake_uuid):
sms_failed=0
)
assert sum_service_usage(service) == 0
def test_platform_admin_list_complaints(
client,
platform_admin_user,
mocker
):
mock_get_user(mocker, user=platform_admin_user)
client.login(platform_admin_user)
complaint = {
'id': str(uuid.uuid4()),
'notification_id': str(uuid.uuid4()),
'service_id': str(uuid.uuid4()),
'service_name': 'Sample service',
'ses_feedback_id': 'Some ses id',
'complaint_type': 'abuse',
'complaint_date': '2018-06-05T13:50:30.012354',
'created_at': '2018-06-05T13:50:30.012354',
}
mock = mocker.patch('app.complaint_api_client.get_all_complaints',
return_value=[complaint])
client.login(platform_admin_user)
response = client.get(url_for('main.platform_admin_list_complaints'))
assert response.status_code == 200
resp_data = response.get_data(as_text=True)
assert 'Email complaints' in resp_data
mock.assert_called_once()

View File

@@ -0,0 +1,10 @@
from app import ComplaintApiClient
def test_get_all_complaints(mocker):
client = ComplaintApiClient()
mock = mocker.patch('app.notify_client.complaint_api_client.ComplaintApiClient.get')
client.get_all_complaints()
mock.assert_called_once_with('/complaint')