mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
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:
@@ -6,6 +6,7 @@ from datetime import datetime
|
||||
from flask import (json, current_app)
|
||||
from freezegun import freeze_time
|
||||
from notifications_python_client.authentication import create_jwt_token
|
||||
from notifications_utils import SMS_CHAR_COUNT_LIMIT
|
||||
|
||||
import app
|
||||
from app.dao import notifications_dao
|
||||
@@ -1020,7 +1021,6 @@ def test_create_template_raises_invalid_request_when_content_too_large(
|
||||
content="((long_text))",
|
||||
template_type=template_type
|
||||
)
|
||||
limit = current_app.config.get('SMS_CHAR_COUNT_LIMIT')
|
||||
template = Template.query.get(sample.id)
|
||||
from app.notifications.rest import create_template_object_for_notification
|
||||
try:
|
||||
@@ -1028,13 +1028,14 @@ def test_create_template_raises_invalid_request_when_content_too_large(
|
||||
{'long_text':
|
||||
''.join(
|
||||
random.choice(string.ascii_uppercase + string.digits) for _ in
|
||||
range(limit + 1))})
|
||||
range(SMS_CHAR_COUNT_LIMIT + 1))})
|
||||
if should_error:
|
||||
pytest.fail("expected an InvalidRequest")
|
||||
except InvalidRequest as e:
|
||||
if not should_error:
|
||||
pytest.fail("do not expect an InvalidRequest")
|
||||
assert e.message == {'content': ['Content has a character count greater than the limit of {}'.format(limit)]}
|
||||
assert e.message == {'content': ['Content has a character count greater than the limit of {}'.format(
|
||||
SMS_CHAR_COUNT_LIMIT)]}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("notification_type, send_to",
|
||||
|
||||
@@ -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 == []
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user