mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
Fix order of callbacks
Delivery comes before inbound. The order of the URLs was jumbled in two places: - in the view function - in the Jinja template So as the user saw it the URLs were in the right order, because the double jumbling cancelled itself out. But it made the code _really_ confusing to read.
This commit is contained in:
@@ -8,6 +8,7 @@ from unittest.mock import call
|
||||
|
||||
from tests import validate_route_permission
|
||||
from tests.conftest import (
|
||||
fake_uuid,
|
||||
mock_get_service,
|
||||
mock_get_live_service,
|
||||
mock_get_service_with_letters,
|
||||
@@ -639,23 +640,52 @@ def test_update_delivery_status_and_receive_text_message_callbacks_without_chang
|
||||
assert mock_update_service_callback_api.called is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize('service_callback_api, delivery_url, expected_1st_table_row', [
|
||||
(
|
||||
None, {},
|
||||
'Callbacks for delivery receipts Not set Change'
|
||||
),
|
||||
(
|
||||
fake_uuid(), {'url': 'https://delivery.receipts'},
|
||||
'Callbacks for delivery receipts https://delivery.receipts Change'
|
||||
),
|
||||
])
|
||||
@pytest.mark.parametrize('inbound_api, inbound_url, expected_2nd_table_row', [
|
||||
(
|
||||
None, {},
|
||||
'Callbacks for received text messages Not set Change'
|
||||
),
|
||||
(
|
||||
fake_uuid(), {'url': 'https://inbound.sms'},
|
||||
'Callbacks for received text messages https://inbound.sms Change'
|
||||
),
|
||||
])
|
||||
def test_callbacks_page_works_when_no_apis_set(
|
||||
client_request,
|
||||
service_one,
|
||||
mocker
|
||||
client_request,
|
||||
service_one,
|
||||
mocker,
|
||||
service_callback_api,
|
||||
delivery_url,
|
||||
expected_1st_table_row,
|
||||
inbound_api,
|
||||
inbound_url,
|
||||
expected_2nd_table_row,
|
||||
):
|
||||
service_one['permissions'] = ['inbound_sms']
|
||||
mocker.patch('app.service_api_client.get_service_callback_api', side_effect={})
|
||||
mocker.patch('app.service_api_client.get_service_inbound_api', side_effect={})
|
||||
service_one['inbound_api'] = inbound_api
|
||||
service_one['service_callback_api'] = service_callback_api
|
||||
|
||||
mocker.patch('app.service_api_client.get_service_callback_api', return_value=delivery_url)
|
||||
mocker.patch('app.service_api_client.get_service_inbound_api', return_value=inbound_url)
|
||||
|
||||
page = client_request.get('main.api_callbacks',
|
||||
service_id=service_one['id'],
|
||||
_follow_redirects=True)
|
||||
expected_rows = [
|
||||
'Callbacks for delivery receipts Not set Change',
|
||||
'Callbacks for received text messages Not set Change',
|
||||
expected_1st_table_row,
|
||||
expected_2nd_table_row,
|
||||
]
|
||||
rows = page.select('tr')
|
||||
assert len(rows) == 3
|
||||
rows = page.select('tbody tr')
|
||||
assert len(rows) == 2
|
||||
for index, row in enumerate(expected_rows):
|
||||
assert row == " ".join(rows[index + 1].text.split())
|
||||
assert row == normalize_spaces(rows[index].text)
|
||||
|
||||
Reference in New Issue
Block a user