mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 13:39:41 -04:00
big commit with letters removal
This commit is contained in:
@@ -32,7 +32,7 @@ def test_client_creates_invite(
|
||||
'from_user': '12345',
|
||||
'service': '67890',
|
||||
'created_by': ANY,
|
||||
'permissions': 'send_emails,send_letters,send_texts',
|
||||
'permissions': 'send_emails,send_texts',
|
||||
'invite_link_host': 'http://localhost:6012',
|
||||
'folder_permissions': [fake_uuid]
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
from unittest.mock import call
|
||||
|
||||
from app.notify_client.letter_branding_client import LetterBrandingClient
|
||||
|
||||
|
||||
def test_get_letter_branding(mocker, fake_uuid):
|
||||
mock_get = mocker.patch(
|
||||
'app.notify_client.letter_branding_client.LetterBrandingClient.get',
|
||||
return_value={'foo': 'bar'}
|
||||
)
|
||||
mock_redis_get = mocker.patch('app.extensions.RedisClient.get', return_value=None)
|
||||
mock_redis_set = mocker.patch('app.extensions.RedisClient.set')
|
||||
|
||||
LetterBrandingClient().get_letter_branding(fake_uuid)
|
||||
|
||||
mock_get.assert_called_once_with(url='/letter-branding/{}'.format(fake_uuid))
|
||||
mock_redis_get.assert_called_once_with('letter_branding-{}'.format(fake_uuid))
|
||||
mock_redis_set.assert_called_once_with(
|
||||
'letter_branding-{}'.format(fake_uuid),
|
||||
'{"foo": "bar"}',
|
||||
ex=604800,
|
||||
)
|
||||
|
||||
|
||||
def test_get_all_letter_branding(mocker):
|
||||
mock_get = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.get', return_value=[1, 2, 3])
|
||||
mock_redis_get = mocker.patch('app.extensions.RedisClient.get', return_value=None)
|
||||
mock_redis_set = mocker.patch('app.extensions.RedisClient.set')
|
||||
|
||||
LetterBrandingClient().get_all_letter_branding()
|
||||
|
||||
mock_get.assert_called_once_with(url='/letter-branding')
|
||||
mock_redis_get.assert_called_once_with('letter_branding')
|
||||
mock_redis_set.assert_called_once_with(
|
||||
'letter_branding',
|
||||
'[1, 2, 3]',
|
||||
ex=604800,
|
||||
)
|
||||
|
||||
|
||||
def test_create_letter_branding(mocker):
|
||||
new_branding = {'filename': 'uuid-test', 'name': 'my letters'}
|
||||
|
||||
mock_post = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.post')
|
||||
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
|
||||
|
||||
LetterBrandingClient().create_letter_branding(
|
||||
filename=new_branding['filename'], name=new_branding['name'],
|
||||
)
|
||||
mock_post.assert_called_once_with(
|
||||
url='/letter-branding',
|
||||
data=new_branding
|
||||
)
|
||||
|
||||
mock_redis_delete.assert_called_once_with('letter_branding')
|
||||
|
||||
|
||||
def test_update_letter_branding(mocker, fake_uuid):
|
||||
branding = {'filename': 'uuid-test', 'name': 'my letters'}
|
||||
|
||||
mock_post = mocker.patch('app.notify_client.letter_branding_client.LetterBrandingClient.post')
|
||||
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
|
||||
LetterBrandingClient().update_letter_branding(
|
||||
branding_id=fake_uuid, filename=branding['filename'], name=branding['name'])
|
||||
|
||||
mock_post.assert_called_once_with(
|
||||
url='/letter-branding/{}'.format(fake_uuid),
|
||||
data=branding
|
||||
)
|
||||
assert mock_redis_delete.call_args_list == [
|
||||
call('letter_branding-{}'.format(fake_uuid)),
|
||||
call('letter_branding'),
|
||||
]
|
||||
@@ -1,9 +1,6 @@
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
from app.notify_client.notification_api_client import NotificationApiClient
|
||||
from tests import notification_json, single_notification_json
|
||||
|
||||
|
||||
@pytest.mark.parametrize("arguments,expected_call", [
|
||||
@@ -96,27 +93,6 @@ def test_send_notification(mocker, client_request, active_user_with_permissions)
|
||||
)
|
||||
|
||||
|
||||
def test_send_precompiled_letter(mocker, client_request, active_user_with_permissions):
|
||||
mock_post = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.post')
|
||||
NotificationApiClient().send_precompiled_letter(
|
||||
'abcd-1234',
|
||||
'my_file.pdf',
|
||||
'file-ID',
|
||||
'second',
|
||||
'Bugs Bunny, 12 Hole Avenue, Looney Town'
|
||||
)
|
||||
mock_post.assert_called_once_with(
|
||||
url='/service/abcd-1234/send-pdf-letter',
|
||||
data={
|
||||
'filename': 'my_file.pdf',
|
||||
'file_id': 'file-ID',
|
||||
'created_by': active_user_with_permissions['id'],
|
||||
'postage': 'second',
|
||||
'recipient_address': 'Bugs Bunny, 12 Hole Avenue, Looney Town',
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_get_notification(mocker):
|
||||
mock_get = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.get')
|
||||
NotificationApiClient().get_notification('foo', 'bar')
|
||||
@@ -125,42 +101,6 @@ def test_get_notification(mocker):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("letter_status, expected_status", [
|
||||
('created', 'accepted'),
|
||||
('sending', 'accepted'),
|
||||
('delivered', 'received'),
|
||||
('returned-letter', 'received'),
|
||||
("technical-failure", "technical-failure")
|
||||
])
|
||||
def test_get_api_notifications_changes_letter_statuses(mocker, letter_status, expected_status):
|
||||
service_id = str(uuid.uuid4())
|
||||
sms_notification = single_notification_json(service_id, notification_type='sms', status='created')
|
||||
email_notification = single_notification_json(service_id, notification_type='email', status='created')
|
||||
letter_notification = single_notification_json(service_id, notification_type='letter', status=letter_status)
|
||||
notis = notification_json(service_id=service_id, rows=0)
|
||||
notis['notifications'] = [sms_notification, email_notification, letter_notification]
|
||||
|
||||
mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.get', return_value=notis)
|
||||
|
||||
ret = NotificationApiClient().get_api_notifications_for_service(service_id)
|
||||
|
||||
assert ret['notifications'][0]['notification_type'] == 'sms'
|
||||
assert ret['notifications'][1]['notification_type'] == 'email'
|
||||
assert ret['notifications'][2]['notification_type'] == 'letter'
|
||||
assert ret['notifications'][0]['status'] == 'created'
|
||||
assert ret['notifications'][1]['status'] == 'created'
|
||||
assert ret['notifications'][2]['status'] == expected_status
|
||||
|
||||
|
||||
def test_update_notification_to_cancelled(mocker):
|
||||
mock_post = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.post')
|
||||
NotificationApiClient().update_notification_to_cancelled('foo', 'bar')
|
||||
mock_post.assert_called_once_with(
|
||||
url='/service/foo/notifications/bar/cancel',
|
||||
data={},
|
||||
)
|
||||
|
||||
|
||||
def test_get_notification_count_for_job_id(mocker):
|
||||
mock_get = mocker.patch('app.notify_client.notification_api_client.NotificationApiClient.get')
|
||||
NotificationApiClient().get_notification_count_for_job_id(service_id='foo', job_id='bar')
|
||||
|
||||
@@ -125,14 +125,6 @@ def test_get_precompiled_template(mocker):
|
||||
{'template_type': 'email'},
|
||||
1,
|
||||
),
|
||||
(
|
||||
[
|
||||
{'template_type': 'email'},
|
||||
{'template_type': 'sms'},
|
||||
],
|
||||
{'template_type': 'letter'},
|
||||
0,
|
||||
),
|
||||
))
|
||||
def test_client_returns_count_of_service_templates(
|
||||
notify_admin,
|
||||
@@ -313,44 +305,6 @@ def test_client_returns_count_of_service_templates(
|
||||
],
|
||||
{'data_from': 'api'},
|
||||
),
|
||||
(
|
||||
service_api_client.get_returned_letter_summary,
|
||||
[SERVICE_ONE_ID],
|
||||
[
|
||||
call('service-{}-returned-letters-summary'.format(SERVICE_ONE_ID))
|
||||
],
|
||||
None,
|
||||
[
|
||||
call('service/{}/returned-letter-summary'.format(SERVICE_ONE_ID))
|
||||
],
|
||||
[
|
||||
call(
|
||||
'service-{}-returned-letters-summary'.format(SERVICE_ONE_ID),
|
||||
'{"data_from": "api"}',
|
||||
ex=604800,
|
||||
)
|
||||
],
|
||||
{'data_from': 'api'},
|
||||
),
|
||||
(
|
||||
service_api_client.get_returned_letter_statistics,
|
||||
[SERVICE_ONE_ID],
|
||||
[
|
||||
call('service-{}-returned-letters-statistics'.format(SERVICE_ONE_ID))
|
||||
],
|
||||
None,
|
||||
[
|
||||
call('service/{}/returned-letter-statistics'.format(SERVICE_ONE_ID))
|
||||
],
|
||||
[
|
||||
call(
|
||||
'service-{}-returned-letters-statistics'.format(SERVICE_ONE_ID),
|
||||
'{"data_from": "api"}',
|
||||
ex=604800,
|
||||
)
|
||||
],
|
||||
{'data_from': 'api'},
|
||||
),
|
||||
]
|
||||
)
|
||||
def test_returns_value_from_cache(
|
||||
@@ -396,9 +350,6 @@ def test_returns_value_from_cache(
|
||||
(service_api_client, 'add_reply_to_email_address', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'update_reply_to_email_address', [SERVICE_ONE_ID] + [''] * 2, {}),
|
||||
(service_api_client, 'delete_reply_to_email_address', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'add_letter_contact', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'update_letter_contact', [SERVICE_ONE_ID] + [''] * 2, {}),
|
||||
(service_api_client, 'delete_letter_contact', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'add_sms_sender', [SERVICE_ONE_ID, ''], {}),
|
||||
(service_api_client, 'update_sms_sender', [SERVICE_ONE_ID] + [''] * 2, {}),
|
||||
(service_api_client, 'delete_sms_sender', [SERVICE_ONE_ID, ''], {}),
|
||||
@@ -440,9 +391,6 @@ def test_deletes_service_cache(
|
||||
('update_service_template_sender', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID, 'foo'], [
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('update_service_template_postage', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID, 'first'], [
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
('delete_service_template', [SERVICE_ONE_ID, FAKE_TEMPLATE_ID], [
|
||||
'service-{}-templates'.format(SERVICE_ONE_ID),
|
||||
]),
|
||||
@@ -563,8 +511,6 @@ def test_client_updates_service_with_allowed_attributes(
|
||||
'free_sms_fragment_limit',
|
||||
'go_live_at',
|
||||
'go_live_user',
|
||||
'letter_branding',
|
||||
'letter_contact_block',
|
||||
'message_limit',
|
||||
'name',
|
||||
'notes',
|
||||
@@ -577,7 +523,6 @@ def test_client_updates_service_with_allowed_attributes(
|
||||
'restricted',
|
||||
'sms_sender',
|
||||
'volume_email',
|
||||
'volume_letter',
|
||||
'volume_sms',
|
||||
]
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ def test_client_converts_admin_permissions_to_db_permissions_on_edit(notify_admi
|
||||
assert sorted(mock_post.call_args[1]['data']['permissions'], key=lambda x: x['permission']) == sorted([
|
||||
{'permission': 'send_texts'},
|
||||
{'permission': 'send_emails'},
|
||||
{'permission': 'send_letters'},
|
||||
{'permission': 'view_activity'},
|
||||
], key=lambda x: x['permission'])
|
||||
|
||||
@@ -113,7 +112,6 @@ def test_client_converts_admin_permissions_to_db_permissions_on_add_to_service(n
|
||||
assert sorted(mock_post.call_args[1]['data']['permissions'], key=lambda x: x['permission']) == sorted([
|
||||
{'permission': 'send_texts'},
|
||||
{'permission': 'send_emails'},
|
||||
{'permission': 'send_letters'},
|
||||
{'permission': 'view_activity'},
|
||||
], key=lambda x: x['permission'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user