mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Add prefix SMS with service name to service model
If the service is sending messages from GOVUK, then its messages should be prefixed with the service name. Right now this logic is: - worked out separately in the admin app and API - isn’t aware of multiple senders This commit moves the logic to one place (the service model). It does this in a slightly naive way, in that it only looks at the default sender, not the actual sender of the message. In the future this will go away because we’ll move it to being a setting that’s controlled independently of the service name. But this is the first step towards that. fixup! Add prefix SMS with service name to service model
This commit is contained in:
@@ -156,6 +156,7 @@ def test_get_service_by_id(client, sample_service):
|
||||
assert json_resp['data']['branding'] == 'govuk'
|
||||
assert json_resp['data']['dvla_organisation'] == '001'
|
||||
assert json_resp['data']['sms_sender'] == current_app.config['FROM_NUMBER']
|
||||
assert json_resp['data']['prefix_sms_with_service_name'] is True
|
||||
|
||||
|
||||
def test_get_service_by_id_returns_free_sms_limit(client, sample_service):
|
||||
@@ -1561,6 +1562,36 @@ def test_set_sms_sender_for_service_rejects_null(client, sample_service):
|
||||
assert result['message'] == {'sms_sender': ['Field may not be null.']}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('default_sms_sender, should_prefix', [
|
||||
(None, True), # None means use default
|
||||
('Foo', False),
|
||||
])
|
||||
def test_prefixing_messages_based_on_sms_sender(
|
||||
client,
|
||||
notify_db_session,
|
||||
default_sms_sender,
|
||||
should_prefix,
|
||||
):
|
||||
service = create_service(
|
||||
sms_sender=default_sms_sender or current_app.config['FROM_NUMBER']
|
||||
)
|
||||
create_service_sms_sender(
|
||||
service=service,
|
||||
sms_sender='ignored',
|
||||
is_default=False,
|
||||
)
|
||||
|
||||
result = client.get(
|
||||
url_for(
|
||||
'service.get_service_by_id',
|
||||
service_id=service.id
|
||||
),
|
||||
headers=[('Content-Type', 'application/json'), create_authorization_header()]
|
||||
)
|
||||
service = json.loads(result.get_data(as_text=True))['data']
|
||||
assert service['prefix_sms_with_service_name'] == should_prefix
|
||||
|
||||
|
||||
@pytest.mark.parametrize('today_only,stats', [
|
||||
('False', {'requested': 2, 'delivered': 1, 'failed': 0}),
|
||||
('True', {'requested': 1, 'delivered': 0, 'failed': 0})
|
||||
|
||||
Reference in New Issue
Block a user