mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-25 02:19:45 -04:00
Update utils to 12.0.0
Includes:
- [x] https://github.com/alphagov/notifications-utils/pull/94 (breaking
changes which are responsible for all the changes to the API in
this PR)
The test for `get_sms_fragment_count` has been removed because this
method is already tested in utils here:
ac20f7e99e/tests/test_base_template.py (L140-L159)
This commit is contained in:
@@ -42,8 +42,6 @@ from app.dao.notifications_dao import (
|
||||
dao_timeout_notifications,
|
||||
get_financial_year)
|
||||
|
||||
from notifications_utils.template import get_sms_fragment_count
|
||||
|
||||
from tests.app.conftest import (sample_notification, sample_template, sample_email_template, sample_service, sample_job,
|
||||
sample_api_key)
|
||||
|
||||
@@ -821,22 +819,6 @@ def test_should_limit_notifications_return_by_day_limit_plus_one(notify_db, noti
|
||||
assert len(all_notifications) == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"char_count, expected_sms_fragment_count",
|
||||
[
|
||||
(159, 1),
|
||||
(160, 1),
|
||||
(161, 2),
|
||||
(306, 2),
|
||||
(307, 3),
|
||||
(459, 3),
|
||||
(460, 4),
|
||||
(461, 4)
|
||||
])
|
||||
def test_sms_fragment_count(char_count, expected_sms_fragment_count):
|
||||
assert get_sms_fragment_count(char_count) == expected_sms_fragment_count
|
||||
|
||||
|
||||
def test_creating_notification_adds_to_notification_history(sample_template):
|
||||
data = _notification_json(sample_template)
|
||||
notification = Notification(**data)
|
||||
|
||||
@@ -355,11 +355,11 @@ def test_send_email_should_use_service_reply_to_email(
|
||||
|
||||
|
||||
def test_get_html_email_renderer_should_return_for_normal_service(sample_service):
|
||||
renderer = send_to_providers.get_html_email_renderer(sample_service)
|
||||
assert renderer.govuk_banner
|
||||
assert renderer.brand_colour is None
|
||||
assert renderer.brand_logo is None
|
||||
assert renderer.brand_name is None
|
||||
options = send_to_providers.get_html_email_options(sample_service)
|
||||
assert options['govuk_banner']
|
||||
assert 'brand_colour' not in options.keys()
|
||||
assert 'brand_logo' not in options.keys()
|
||||
assert 'brand_name' not in options.keys()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('branding_type, govuk_banner', [
|
||||
@@ -373,11 +373,11 @@ def test_get_html_email_renderer_with_branding_details(branding_type, govuk_bann
|
||||
notify_db.session.add_all([sample_service, org])
|
||||
notify_db.session.commit()
|
||||
|
||||
renderer = send_to_providers.get_html_email_renderer(sample_service)
|
||||
options = send_to_providers.get_html_email_options(sample_service)
|
||||
|
||||
assert renderer.govuk_banner == govuk_banner
|
||||
assert renderer.brand_colour == '000000'
|
||||
assert renderer.brand_name == 'Justice League'
|
||||
assert options['govuk_banner'] == govuk_banner
|
||||
assert options['brand_colour'] == '#000000'
|
||||
assert options['brand_name'] == 'Justice League'
|
||||
|
||||
|
||||
def test_get_html_email_renderer_prepends_logo_path(notify_db, sample_service):
|
||||
@@ -387,9 +387,9 @@ def test_get_html_email_renderer_prepends_logo_path(notify_db, sample_service):
|
||||
notify_db.session.add_all([sample_service, org])
|
||||
notify_db.session.commit()
|
||||
|
||||
renderer = send_to_providers.get_html_email_renderer(sample_service)
|
||||
renderer = send_to_providers.get_html_email_options(sample_service)
|
||||
|
||||
assert renderer.brand_logo == 'http://localhost:6012/static/images/email-template/crests/justice-league.png'
|
||||
assert renderer['brand_logo'] == 'http://localhost:6012/static/images/email-template/crests/justice-league.png'
|
||||
|
||||
|
||||
def test_should_not_set_billable_units_if_research_mode(notify_db, sample_service, sample_notification, mocker):
|
||||
|
||||
@@ -129,7 +129,7 @@ def test_send_notification_with_placeholders_replaced(notify_api, sample_email_t
|
||||
queue="send-email"
|
||||
)
|
||||
assert response.status_code == 201
|
||||
assert response_data['body'] == 'Hello Jo\nThis is an email from GOV.UK'
|
||||
assert response_data['body'] == u'Hello Jo\nThis is an email from GOV.\u200BUK'
|
||||
assert response_data['subject'] == 'Jo'
|
||||
|
||||
|
||||
|
||||
@@ -18,14 +18,14 @@ from tests.app.conftest import sample_notification, sample_template, sample_emai
|
||||
def test_create_content_for_notification_passes(sample_email_template):
|
||||
template = Template.query.get(sample_email_template.id)
|
||||
content = create_content_for_notification(template, None)
|
||||
assert content.rendered == template.content
|
||||
assert str(content) == template.content
|
||||
|
||||
|
||||
def test_create_content_for_notification_with_placeholders_passes(sample_template_with_placeholders):
|
||||
template = Template.query.get(sample_template_with_placeholders.id)
|
||||
content = create_content_for_notification(template, {'name': 'Bobby'})
|
||||
assert content.content == template.content
|
||||
assert 'Bobby' in content.rendered
|
||||
assert 'Bobby' in str(content)
|
||||
|
||||
|
||||
def test_create_content_for_notification_fails_with_missing_personalisation(sample_template_with_placeholders):
|
||||
|
||||
@@ -711,7 +711,7 @@ def test_get_notification_by_id_returns_merged_template_content_for_email(
|
||||
|
||||
notification = json.loads(response.get_data(as_text=True))['data']['notification']
|
||||
assert response.status_code == 200
|
||||
assert notification['body'] == 'Hello world\nThis is an email from GOV.UK'
|
||||
assert notification['body'] == 'Hello world\nThis is an email from GOV.\u200BUK'
|
||||
assert notification['subject'] == 'world'
|
||||
assert notification['content_char_count'] is None
|
||||
|
||||
|
||||
@@ -129,8 +129,10 @@ def test_post_email_notification_returns_201(client, sample_email_template_with_
|
||||
assert resp_json['id'] == str(notification.id)
|
||||
assert resp_json['reference'] == reference
|
||||
assert notification.reference is None
|
||||
assert resp_json['content']['body'] == sample_email_template_with_placeholders.content.replace('((name))', 'Bob')
|
||||
assert resp_json['content']['subject'] == sample_email_template_with_placeholders.subject
|
||||
assert resp_json['content']['body'] == sample_email_template_with_placeholders.content\
|
||||
.replace('((name))', 'Bob').replace('GOV.UK', u'GOV.\u200bUK')
|
||||
assert resp_json['content']['subject'] == sample_email_template_with_placeholders.subject\
|
||||
.replace('((name))', 'Bob')
|
||||
assert resp_json['content']['from_email'] == sample_email_template_with_placeholders.service.email_from
|
||||
assert 'v2/notifications/{}'.format(notification.id) in resp_json['uri']
|
||||
assert resp_json['template']['id'] == str(sample_email_template_with_placeholders.id)
|
||||
|
||||
Reference in New Issue
Block a user