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'])
    assert e.value.fields == []
Example #2
0
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(
        SMS_CHAR_COUNT_LIMIT)
    assert e.value.fields == []
def __validate_template(form, service, notification_type):
    try:
        template = templates_dao.dao_get_template_by_id_and_service_id(
            template_id=form["template_id"], service_id=service.id
        )
    except NoResultFound:
        message = "Template not found"
        raise BadRequestError(message=message, fields=[{"template": message}])

    check_template_is_for_notification_type(notification_type, template.template_type)
    check_template_is_active(template)
    template_with_content = create_content_for_notification(template, form.get("personalisation", {}))
    if template.template_type == SMS_TYPE:
        check_sms_content_char_count(template_with_content.content_count)
    return template, template_with_content
def test_check_sms_content_char_count_passes(char_count, notify_api):
    assert check_sms_content_char_count(char_count) is None
Example #5
0
def test_check_sms_content_char_count_passes(char_count, notify_api):
    assert check_sms_content_char_count(char_count) is None