diff --git a/app/models.py b/app/models.py index 0fe4b0a6e..3fce77c60 100644 --- a/app/models.py +++ b/app/models.py @@ -199,7 +199,7 @@ class Service(db.Model, Versioned): created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False) reply_to_email_address = db.Column(db.Text, index=False, unique=False, nullable=True) letter_contact_block = db.Column(db.Text, index=False, unique=False, nullable=True) - sms_sender = db.Column(db.String(11), nullable=True, default='GOVUK') + sms_sender = db.Column(db.String(11), nullable=True, default=lambda: current_app.config['FROM_NUMBER']) organisation_id = db.Column(UUID(as_uuid=True), db.ForeignKey('organisation.id'), index=True, nullable=True) organisation = db.relationship('Organisation') dvla_organisation_id = db.Column( diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 7ab0ba793..126e9b948 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -5,7 +5,7 @@ import uuid from unittest.mock import ANY import pytest -from flask import url_for +from flask import url_for, current_app from freezegun import freeze_time from app.dao.users_dao import save_model_user @@ -144,7 +144,7 @@ def test_get_service_by_id(client, sample_service): assert json_resp['data']['organisation'] is None assert json_resp['data']['branding'] == 'govuk' assert json_resp['data']['dvla_organisation'] == '001' - assert json_resp['data']['sms_sender'] == 'GOVUK' + assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER'] def test_get_service_by_id_should_404_if_no_service(notify_api, notify_db): @@ -214,7 +214,7 @@ def test_create_service(client, sample_user): assert json_resp['data']['email_from'] == 'created.service' assert not json_resp['data']['research_mode'] assert json_resp['data']['dvla_organisation'] == '001' - assert json_resp['data']['sms_sender'] == 'GOVUK' + assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER'] auth_header_fetch = create_authorization_header() diff --git a/tests/app/service/test_sender.py b/tests/app/service/test_sender.py index 3223e9e71..cb6ee93fd 100644 --- a/tests/app/service/test_sender.py +++ b/tests/app/service/test_sender.py @@ -109,5 +109,4 @@ def test_send_notification_to_service_users_sends_to_active_users_only( assert Notification.query.count() == 2 - assert notifications[0].to == first_active_user.email_address - assert notifications[1].to == second_active_user.email_address + assert pending_user.email_address not in [n.to for n in notifications] diff --git a/tests/app/v2/notifications/test_post_notifications.py b/tests/app/v2/notifications/test_post_notifications.py index 606f0ed42..4e721f15f 100644 --- a/tests/app/v2/notifications/test_post_notifications.py +++ b/tests/app/v2/notifications/test_post_notifications.py @@ -1,6 +1,8 @@ import uuid + import pytest -from flask import json +from flask import json, current_app + from app.models import Notification from app.v2.errors import RateLimitError from tests import create_authorization_header @@ -33,8 +35,7 @@ def test_post_sms_notification_returns_201(notify_api, sample_template_with_plac assert resp_json['id'] == str(notification_id) assert resp_json['reference'] == reference assert resp_json['content']['body'] == sample_template_with_placeholders.content.replace("(( Name))", "Jo") - # conftest fixture service does not have a sms sender, use config default - assert resp_json['content']['from_number'] == 'GOVUK' + assert resp_json['content']['from_number'] == current_app.config['FROM_NUMBER'] assert 'v2/notifications/{}'.format(notification_id) in resp_json['uri'] assert resp_json['template']['id'] == str(sample_template_with_placeholders.id) assert resp_json['template']['version'] == sample_template_with_placeholders.version