mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 18:22:37 -04:00
Rename API client methods to remove term ‘whitelist’
See c31264d4c for rationale. To avoid confusion the codebase should use
the same terminology as the UI.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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=''):
|
||||
|
||||
@@ -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', [
|
||||
|
||||
@@ -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, ''], {}),
|
||||
|
||||
+5
-5
@@ -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'
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user