Use new value of SMS_CHAR_COUNT_LIMIT from utils

Admin, API and utils were all defining a value for SMS_CHAR_COUNT_LIMIT.
This value has been updated in notifications-utils to allow text
messages to be 4 fragments long and notifications-api now gets the value of
SMS_CHAR_COUNT_LIMIT from notifications-utils instead of defining it in
config.

Also updated some tests to check for the higher limit.
This commit is contained in:
Katie Smith
2018-08-16 16:25:58 +01:00
parent 85af1e7fe8
commit a87be9b74a
8 changed files with 29 additions and 28 deletions

View File

@@ -1,6 +1,7 @@
import pytest
from freezegun import freeze_time
from flask import current_app
from notifications_utils import SMS_CHAR_COUNT_LIMIT
import app
from app.models import INTERNATIONAL_SMS_TYPE, SMS_TYPE, EMAIL_TYPE, LETTER_TYPE
@@ -264,18 +265,18 @@ def test_service_can_send_to_recipient_fails_when_mobile_number_is_not_on_team(n
assert e.value.fields == []
@pytest.mark.parametrize('char_count', [495, 0, 494, 200])
@pytest.mark.parametrize('char_count', [612, 0, 494, 200])
def test_check_sms_content_char_count_passes(char_count, notify_api):
assert check_sms_content_char_count(char_count) is None
@pytest.mark.parametrize('char_count', [496, 500, 6000])
@pytest.mark.parametrize('char_count', [613, 700, 6000])
def test_check_sms_content_char_count_fails(char_count, notify_api):
with pytest.raises(BadRequestError) as e:
check_sms_content_char_count(char_count)
assert e.value.status_code == 400
assert e.value.message == 'Content for template has a character count greater than the limit of {}'.format(
notify_api.config['SMS_CHAR_COUNT_LIMIT'])
SMS_CHAR_COUNT_LIMIT)
assert e.value.fields == []