mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-27 04:31:11 -04:00
Merge pull request #602 from alphagov/delete-button
delete template button POSTs archived:true
This commit is contained in:
@@ -159,11 +159,14 @@ class ServiceAPIClient(NotificationsAPIClient):
|
||||
|
||||
def delete_service_template(self, service_id, template_id):
|
||||
"""
|
||||
Delete a service template.
|
||||
Set a service template's archived flag to True
|
||||
"""
|
||||
endpoint = "/service/{0}/template/{1}".format(service_id, template_id)
|
||||
data = _attach_current_user({})
|
||||
return self.delete(endpoint)
|
||||
data = {
|
||||
'archived': True
|
||||
}
|
||||
_attach_current_user(data)
|
||||
return self.post(endpoint, data=data)
|
||||
|
||||
def find_all_service_email_from(self, user_id=None):
|
||||
resp = self.get_services(user_id)
|
||||
|
||||
0
tests/app/notify_client/__init__.py
Normal file
0
tests/app/notify_client/__init__.py
Normal file
21
tests/app/notify_client/test_api_client.py
Normal file
21
tests/app/notify_client/test_api_client.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from app.notify_client.api_client import ServiceAPIClient
|
||||
from tests.conftest import fake_uuid
|
||||
|
||||
|
||||
def test_client_posts_archived_true_when_deleting_template(mocker):
|
||||
service_id = fake_uuid
|
||||
template_id = fake_uuid
|
||||
|
||||
expected_data = {
|
||||
'archived': True,
|
||||
'created_by': fake_uuid
|
||||
}
|
||||
expected_url = '/service/{}/template/{}'.format(service_id, template_id)
|
||||
|
||||
client = ServiceAPIClient()
|
||||
mock_post = mocker.patch('app.notify_client.api_client.ServiceAPIClient.post')
|
||||
mock_attach_user = mocker.patch('app.notify_client.api_client._attach_current_user',
|
||||
side_effect=lambda x: x.update({'created_by': fake_uuid}))
|
||||
|
||||
client.delete_service_template(service_id, template_id)
|
||||
mock_post.assert_called_once_with(expected_url, data=expected_data)
|
||||
Reference in New Issue
Block a user