This massive set of changes uses the new queue names object throughout the app and tests.

Lots of changes, all changing the line of code that puts things into queues, and the code that tests that.
This commit is contained in:
Martyn Inglis
2017-05-25 10:51:49 +01:00
parent 21586c917c
commit 2591d3a1df
28 changed files with 128 additions and 123 deletions

View File

@@ -68,7 +68,7 @@ def test_dvla_callback_calls_update_letter_notifications_task(client, mocker):
assert response.status_code == 200
assert update_task.called
update_task.assert_called_with(['bar.txt'], queue='notify')
update_task.assert_called_with(['bar.txt'], queue='notify-internal-tasks')
def test_dvla_callback_does_not_raise_error_parsing_json_for_plaintext_header(client, mocker):

View File

@@ -127,7 +127,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t
mocked.assert_called_once_with(
[notification_id],
queue="send-email"
queue="send-tasks"
)
assert response.status_code == 201
assert response_data['body'] == u'Hello Jo\nThis is an email from GOV.\u200BUK'
@@ -338,7 +338,7 @@ def test_should_allow_valid_sms_notification(notify_api, sample_template, mocker
response_data = json.loads(response.data)['data']
notification_id = response_data['notification']['id']
mocked.assert_called_once_with([notification_id], queue='send-sms')
mocked.assert_called_once_with([notification_id], queue='send-tasks')
assert response.status_code == 201
assert notification_id
assert 'subject' not in response_data
@@ -392,7 +392,7 @@ def test_should_allow_valid_email_notification(notify_api, sample_email_template
notification_id = response_data['notification']['id']
app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with(
[notification_id],
queue="send-email"
queue="send-tasks"
)
assert response.status_code == 201
@@ -593,7 +593,7 @@ def test_should_send_email_if_team_api_key_and_a_service_user(notify_api, sample
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))])
app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with([fake_uuid], queue='send-email')
app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with([fake_uuid], queue='send-tasks')
assert response.status_code == 201
@@ -626,7 +626,9 @@ def test_should_send_sms_to_anyone_with_test_key(
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))]
)
app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with([fake_uuid], queue='research-mode')
app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with(
[fake_uuid], queue='research-mode-tasks'
)
assert response.status_code == 201
@@ -660,7 +662,9 @@ def test_should_send_email_to_anyone_with_test_key(
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))]
)
app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with([fake_uuid], queue='research-mode')
app.celery.provider_tasks.deliver_email.apply_async.assert_called_once_with(
[fake_uuid], queue='research-mode-tasks'
)
assert response.status_code == 201
@@ -685,7 +689,7 @@ def test_should_send_sms_if_team_api_key_and_a_service_user(notify_api, sample_t
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))])
app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with([fake_uuid], queue='send-sms')
app.celery.provider_tasks.deliver_sms.apply_async.assert_called_once_with([fake_uuid], queue='send-tasks')
assert response.status_code == 201
@@ -718,7 +722,7 @@ def test_should_persist_notification(notify_api, sample_template,
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))])
mocked.assert_called_once_with([fake_uuid], queue='send-{}'.format(template_type))
mocked.assert_called_once_with([fake_uuid], queue='send-tasks')
assert response.status_code == 201
notification = notifications_dao.get_notification_by_id(fake_uuid)
@@ -761,7 +765,7 @@ def test_should_delete_notification_and_return_error_if_sqs_fails(
data=json.dumps(data),
headers=[('Content-Type', 'application/json'), ('Authorization', 'Bearer {}'.format(auth_header))])
mocked.assert_called_once_with([fake_uuid], queue='send-{}'.format(template_type))
mocked.assert_called_once_with([fake_uuid], queue='send-tasks')
assert response.status_code == 500
assert not notifications_dao.get_notification_by_id(fake_uuid)
assert not NotificationHistory.query.get(fake_uuid)
@@ -1046,7 +1050,7 @@ def test_send_notification_uses_priority_queue_when_template_is_marked_as_priori
notification_id = response_data['notification']['id']
assert response.status_code == 201
mocked.assert_called_once_with([notification_id], queue='priority')
mocked.assert_called_once_with([notification_id], queue='priority-tasks')
@pytest.mark.parametrize(
@@ -1114,7 +1118,7 @@ def test_should_allow_store_original_number_on_sms_notification(client, sample_t
response_data = json.loads(response.data)['data']
notification_id = response_data['notification']['id']
mocked.assert_called_once_with([notification_id], queue='send-sms')
mocked.assert_called_once_with([notification_id], queue='send-tasks')
assert response.status_code == 201
assert notification_id
notifications = Notification.query.all()

View File

@@ -207,17 +207,17 @@ def test_persist_notification_increments_cache_if_key_exists(sample_template, sa
@pytest.mark.parametrize('research_mode, requested_queue, expected_queue, notification_type, key_type',
[(True, None, 'research-mode', 'sms', 'normal'),
(True, None, 'research-mode', 'email', 'normal'),
(True, None, 'research-mode', 'email', 'team'),
(False, None, 'send-sms', 'sms', 'normal'),
(False, None, 'send-email', 'email', 'normal'),
(False, None, 'send-sms', 'sms', 'team'),
(False, None, 'research-mode', 'sms', 'test'),
(True, 'notify', 'research-mode', 'email', 'normal'),
(False, 'notify', 'notify', 'sms', 'normal'),
(False, 'notify', 'notify', 'email', 'normal'),
(False, 'notify', 'research-mode', 'sms', 'test')])
[(True, None, 'research-mode-tasks', 'sms', 'normal'),
(True, None, 'research-mode-tasks', 'email', 'normal'),
(True, None, 'research-mode-tasks', 'email', 'team'),
(False, None, 'send-tasks', 'sms', 'normal'),
(False, None, 'send-tasks', 'email', 'normal'),
(False, None, 'send-tasks', 'sms', 'team'),
(False, None, 'research-mode-tasks', 'sms', 'test'),
(True, 'notify-internal-tasks', 'research-mode-tasks', 'email', 'normal'),
(False, 'notify-internal-tasks', 'notify-internal-tasks', 'sms', 'normal'),
(False, 'notify-internal-tasks', 'notify-internal-tasks', 'email', 'normal'),
(False, 'notify-internal-tasks', 'research-mode-tasks', 'sms', 'test')])
def test_send_notification_to_queue(notify_db, notify_db_session,
research_mode, requested_queue, expected_queue,
notification_type, key_type, mocker):