mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
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:
@@ -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',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user