From 16cc64082269f106654653b991f5a43e57fd4ecf Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 12 Jun 2020 09:05:26 +0100 Subject: [PATCH] =?UTF-8?q?Rename=20API=20client=20methods=20to=20remove?= =?UTF-8?q?=20term=20=E2=80=98whitelist=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See c31264d4c for rationale. To avoid confusion the codebase should use the same terminology as the UI. --- app/main/views/api_keys.py | 4 ++-- app/notify_client/service_api_client.py | 4 ++-- tests/app/main/views/test_api_integration.py | 10 +++++----- tests/app/notify_client/test_service_api_client.py | 2 +- tests/conftest.py | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/main/views/api_keys.py b/app/main/views/api_keys.py index fd9aa949b..21117997e 100644 --- a/app/main/views/api_keys.py +++ b/app/main/views/api_keys.py @@ -57,14 +57,14 @@ def api_documentation(service_id): def guest_list(service_id): form = GuestList() if form.validate_on_submit(): - service_api_client.update_whitelist(service_id, { + service_api_client.update_guest_list(service_id, { 'email_addresses': list(filter(None, form.email_addresses.data)), 'phone_numbers': list(filter(None, form.phone_numbers.data)) }) flash('Guest list updated', 'default_with_tick') return redirect(url_for('.api_integration', service_id=service_id)) if not form.errors: - form.populate(**service_api_client.get_whitelist(service_id)) + form.populate(**service_api_client.get_guest_list(service_id)) return render_template( 'views/api/whitelist.html', form=form diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 7378e2de1..1747a171f 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -326,11 +326,11 @@ class ServiceAPIClient(NotifyAdminAPIClient): def get_monthly_notification_stats(self, service_id, year): return self.get(url='/service/{}/notifications/monthly?year={}'.format(service_id, year)) - def get_whitelist(self, service_id): + def get_guest_list(self, service_id): return self.get(url='/service/{}/whitelist'.format(service_id)) @cache.delete('service-{service_id}') - def update_whitelist(self, service_id, data): + def update_guest_list(self, service_id, data): return self.put(url='/service/{}/whitelist'.format(service_id), data=data) def get_inbound_sms(self, service_id, user_number=''): diff --git a/tests/app/main/views/test_api_integration.py b/tests/app/main/views/test_api_integration.py index dd15da606..c3ecce6c4 100644 --- a/tests/app/main/views/test_api_integration.py +++ b/tests/app/main/views/test_api_integration.py @@ -418,7 +418,7 @@ def test_should_show_whitelist_page( api_user_active, mock_get_service, mock_has_permissions, - mock_get_whitelist, + mock_get_guest_list, ): page = client_request.get( 'main.guest_list', @@ -433,7 +433,7 @@ def test_should_show_whitelist_page( def test_should_update_whitelist( client_request, - mock_update_whitelist, + mock_update_guest_list, ): data = OrderedDict([ ('email_addresses-1', 'test@example.com'), @@ -448,14 +448,14 @@ def test_should_update_whitelist( _data=data, ) - mock_update_whitelist.assert_called_once_with(SERVICE_ONE_ID, { + mock_update_guest_list.assert_called_once_with(SERVICE_ONE_ID, { 'email_addresses': ['test@example.com', 'test@example.com'], 'phone_numbers': ['07900900000', '+1800-555-555']}) def test_should_validate_whitelist_items( client_request, - mock_update_whitelist, + mock_update_guest_list, ): page = client_request.post( @@ -477,7 +477,7 @@ def test_should_validate_whitelist_items( assert jump_links[1].string.strip() == 'Enter valid phone numbers' assert jump_links[1]['href'] == '#phone_numbers' - assert mock_update_whitelist.called is False + assert mock_update_guest_list.called is False @pytest.mark.parametrize('endpoint', [ diff --git a/tests/app/notify_client/test_service_api_client.py b/tests/app/notify_client/test_service_api_client.py index 1b5703d56..d3de2c0cf 100644 --- a/tests/app/notify_client/test_service_api_client.py +++ b/tests/app/notify_client/test_service_api_client.py @@ -393,7 +393,7 @@ def test_returns_value_from_cache( (service_api_client, 'suspend_service', [SERVICE_ONE_ID], {}), (service_api_client, 'resume_service', [SERVICE_ONE_ID], {}), (service_api_client, 'remove_user_from_service', [SERVICE_ONE_ID, ''], {}), - (service_api_client, 'update_whitelist', [SERVICE_ONE_ID, {}], {}), + (service_api_client, 'update_guest_list', [SERVICE_ONE_ID, {}], {}), (service_api_client, 'create_service_inbound_api', [SERVICE_ONE_ID] + [''] * 3, {}), (service_api_client, 'update_service_inbound_api', [SERVICE_ONE_ID] + [''] * 4, {}), (service_api_client, 'add_reply_to_email_address', [SERVICE_ONE_ID, ''], {}), diff --git a/tests/conftest.py b/tests/conftest.py index 25b5b083d..b819c457e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2827,22 +2827,22 @@ def mock_update_email_branding(mocker): @pytest.fixture(scope='function') -def mock_get_whitelist(mocker): - def _get_whitelist(service_id): +def mock_get_guest_list(mocker): + def _get_guest_list(service_id): return { 'email_addresses': ['test@example.com'], 'phone_numbers': ['07900900000'] } return mocker.patch( - 'app.service_api_client.get_whitelist', side_effect=_get_whitelist + 'app.service_api_client.get_guest_list', side_effect=_get_guest_list ) @pytest.fixture(scope='function') -def mock_update_whitelist(mocker): +def mock_update_guest_list(mocker): return mocker.patch( - 'app.service_api_client.update_whitelist' + 'app.service_api_client.update_guest_list' )