Make send the send flow generic

This commit parameterises all methods in the send view so that they can send
either emails or SMS messages.

It works out what kind of message it is sending from the `template_type`
property of the template object.

This means that the `Template` util class needs to know about these properties,
which means that this commit depends on:
https://github.com/alphagov/notifications-utils/pull/2

This commit does _not_ add tests for sending emails. The existing tests for
sending SMS still pass, but actually sending emails is outside the scope of
this story.
This commit is contained in:
Chris Hill-Scott
2016-02-22 17:17:18 +00:00
parent aaa6317371
commit 1e46922876
13 changed files with 174 additions and 103 deletions

View File

@@ -163,11 +163,20 @@ def mock_update_service_template(mocker):
@pytest.fixture(scope='function')
def mock_get_service_templates(mocker):
def _create(service_id):
template_one = template_json(
1, "template_one", "sms", "template one content", service_id)
template_two = template_json(
2, "template_two", "sms", "template two content", service_id)
return {'data': [template_one, template_two]}
return {'data': [
template_json(
1, "sms_template_one", "sms", "sms template one content", service_id
),
template_json(
2, "sms_template_two", "sms", "sms template two content", service_id
),
template_json(
3, "email_template_one", "email", "email template one content", service_id
),
template_json(
4, "email_template_two", "email", "email template two content", service_id
)
]}
return mocker.patch(
'app.notifications_api_client.get_service_templates',