add broadcast to template_types and add broadcast_data

had to go through the code and change a few places where we filter on
template types. i specifically didn't worry about jobs or notifications.

Also, add braodcast_data - a json column that might contain arbitrary
broadcast data that we'll figure out as we go. We don't know what it'll
look like, but it should be returned by the API
This commit is contained in:
Leo Hemsted
2020-07-02 12:12:34 +01:00
parent 3954cd0e4a
commit 7ecd7341b0
12 changed files with 45 additions and 22 deletions

View File

@@ -14,6 +14,7 @@ from notifications_utils import SMS_CHAR_COUNT_LIMIT
from app.models import (
BROADCAST_TYPE,
EMAIL_TYPE,
LETTER_TYPE,
SMS_TYPE,
@@ -31,6 +32,7 @@ from tests.conftest import set_config_values
@pytest.mark.parametrize('template_type, subject', [
(BROADCAST_TYPE, None),
(SMS_TYPE, None),
(EMAIL_TYPE, 'subject'),
(LETTER_TYPE, 'subject'),
@@ -529,6 +531,7 @@ def test_should_get_return_all_fields_by_default(
)
assert json_response['data'][0].keys() == {
'archived',
'broadcast_data',
'content',
'created_at',
'created_by',

View File

@@ -3,7 +3,7 @@ import pytest
from flask import json
from app import DATETIME_FORMAT
from app.models import TEMPLATE_TYPES, EMAIL_TYPE, SMS_TYPE, LETTER_TYPE
from app.models import (TEMPLATE_TYPES, EMAIL_TYPE, SMS_TYPE, LETTER_TYPE,)
from tests import create_authorization_header
from tests.app.db import create_template, create_letter_contact
@@ -44,6 +44,7 @@ def test_get_template_by_id_returns_200(
'name': expected_name,
'personalisation': {},
'postage': postage,
'broadcast_data': None,
}
assert json_response == expected_response

View File

@@ -97,7 +97,7 @@ def test_valid_post_template_returns_200(
assert resp_json['id'] == str(template.id)
if tmp_type != SMS_TYPE:
if tmp_type in {EMAIL_TYPE, LETTER_TYPE}:
assert expected_subject in resp_json['subject']
if tmp_type == EMAIL_TYPE:

View File

@@ -112,7 +112,7 @@ def test_get_all_templates_for_invalid_type_returns_400(client, sample_service):
'status_code': 400,
'errors': [
{
'message': 'type coconut is not one of [sms, email, letter]',
'message': 'type coconut is not one of [sms, email, letter, broadcast]',
'error': 'ValidationError'
}
]

View File

@@ -242,7 +242,7 @@ def test_get_all_template_request_schema_against_invalid_args_is_invalid(templat
assert errors['status_code'] == 400
assert len(errors['errors']) == 1
assert errors['errors'][0]['message'] == 'type unknown is not one of [sms, email, letter]'
assert errors['errors'][0]['message'] == 'type unknown is not one of [sms, email, letter, broadcast]'
@pytest.mark.parametrize("response", valid_json_get_all_response)