mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Replace sevice api client get template calls with Service methods
Instead of using the API client directly views are now calling one of two Service model methods: `get_template` is used for view actions, where the user should see the template page even if they don't have access to the template folder (since all templates are still inked from the dashboard or the sent notifications pages). `get_template_with_user_permission_or_403` will check if the user has access to the template's folder first and return 403 otherwise. This method is used for any endpoints that result in an action: editing template attributes, deleting templates or sending messages.
This commit is contained in:
@@ -1823,7 +1823,7 @@ def test_send_test_works_as_letter_preview(
|
||||
)
|
||||
)
|
||||
|
||||
mock_get_service_letter_template.assert_called_with(service_id, template_id)
|
||||
mock_get_service_letter_template.assert_called_with(service_id, template_id, None)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == 'foo'
|
||||
@@ -2187,7 +2187,7 @@ def test_should_show_preview_letter_message(
|
||||
)
|
||||
)
|
||||
|
||||
mock_get_service_letter_template.assert_called_with(service_id, template_id)
|
||||
mock_get_service_letter_template.assert_called_with(service_id, template_id, None)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == 'foo'
|
||||
@@ -3121,6 +3121,7 @@ def test_send_notification_submits_data(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_send_notification,
|
||||
mock_get_service_template,
|
||||
template,
|
||||
recipient,
|
||||
placeholders,
|
||||
@@ -3150,6 +3151,7 @@ def test_send_notification_clears_session(
|
||||
service_one,
|
||||
fake_uuid,
|
||||
mock_send_notification,
|
||||
mock_get_service_template,
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
session['recipient'] = '07700900001'
|
||||
@@ -3195,6 +3197,7 @@ def test_send_notification_redirects_to_view_page(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_send_notification,
|
||||
mock_get_service_template,
|
||||
extra_args,
|
||||
extra_redirect_args
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user