From 9e600b605176145e8ca7e2b6aa271259d3d58902 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 6 Nov 2017 15:08:34 +0000 Subject: [PATCH] POST to the correct endpoint when updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `prefix_sms_with_service_name` is a computed attribute on the service model. It’s where we get the value from, and the API does some work to get it from the database, or derive it from the default SMS sender. It can’t be updated, because it’s not itself a database column. `prefix_sms` is the name of the actual database column. This is the thing that we need to update. This will go away eventually. --- app/main/views/service_settings.py | 2 +- app/notify_client/service_api_client.py | 2 +- tests/app/main/views/test_service_settings.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 55f7ade46..79d823084 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -502,7 +502,7 @@ def service_set_sms_prefix(service_id): if form.validate_on_submit(): service_api_client.update_service( current_service['id'], - prefix_sms_with_service_name=(form.enabled.data == 'on') + prefix_sms=(form.enabled.data == 'on') ) return redirect(url_for('.service_settings', service_id=service_id)) diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 3667ecba2..2d7b1975b 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -107,7 +107,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): 'permissions', 'organisation_type', 'free_sms_fragment_limit', - 'prefix_sms_with_service_name', + 'prefix_sms', } if disallowed_attributes: raise TypeError('Not allowed to update service attributes: {}'.format( diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index ca180e3a6..08d3d19fa 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -2108,5 +2108,5 @@ def test_updates_sms_prefixing( ) mock_update_service.assert_called_once_with( service_id=SERVICE_ONE_ID, - prefix_sms_with_service_name=expected_api_argument, + prefix_sms=expected_api_argument, )