mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Merge pull request #681 from alphagov/tables-of-notifications
Make dashboard and activity pages consistently clickable
This commit is contained in:
@@ -91,11 +91,15 @@ def test_should_show_recent_templates_on_dashboard(app_,
|
||||
|
||||
assert len(table_rows) == 2
|
||||
|
||||
assert page.find_all('dt')[0].text.strip() == 'Pickle feet'
|
||||
assert page.find_all('dd')[0].text.strip() == '206 text messages sent'
|
||||
assert 'Pickle feet' in page.find_all('dt')[0].text
|
||||
assert 'Text message template' in page.find_all('dt')[0].text
|
||||
assert '206' in page.find_all('dd')[0].text
|
||||
assert 'text messages sent' in page.find_all('dd')[0].text
|
||||
|
||||
assert page.find_all('dt')[1].text.strip() == 'Brine Shrimp'
|
||||
assert page.find_all('dd')[1].text.strip() == '13 text messages sent'
|
||||
assert 'Brine Shrimp' in page.find_all('dt')[1].text
|
||||
assert 'Text message template' in page.find_all('dt')[1].text
|
||||
assert '13' in page.find_all('dd')[1].text
|
||||
assert 'text messages sent' in page.find_all('dd')[1].text
|
||||
|
||||
|
||||
def test_should_show_all_templates_on_template_statistics_page(
|
||||
@@ -129,11 +133,15 @@ def test_should_show_all_templates_on_template_statistics_page(
|
||||
|
||||
assert len(table_rows) == 2
|
||||
|
||||
assert page.find_all('dt')[0].text.strip() == 'Pickle feet'
|
||||
assert page.find_all('dd')[0].text.strip() == '206 text messages sent'
|
||||
assert 'Pickle feet' in page.find_all('dt')[0].text
|
||||
assert 'Text message template' in page.find_all('dt')[0].text
|
||||
assert '206' in page.find_all('dd')[0].text
|
||||
assert 'text messages sent' in page.find_all('dd')[0].text
|
||||
|
||||
assert page.find_all('dt')[1].text.strip() == 'Brine Shrimp'
|
||||
assert page.find_all('dd')[1].text.strip() == '13 text messages sent'
|
||||
assert 'Brine Shrimp' in page.find_all('dt')[1].text
|
||||
assert 'Text message template' in page.find_all('dt')[1].text
|
||||
assert '13' in page.find_all('dd')[1].text
|
||||
assert 'text messages sent' in page.find_all('dd')[1].text
|
||||
|
||||
|
||||
def _test_dashboard_menu(mocker, app_, usr, service, permissions):
|
||||
|
||||
@@ -26,22 +26,54 @@ def test_should_return_list_of_all_jobs(app_,
|
||||
assert len(jobs) == 5
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"status_argument, expected_api_call", [
|
||||
(
|
||||
'',
|
||||
['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||
),
|
||||
(
|
||||
'processed',
|
||||
['sending', 'delivered', 'failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||
),
|
||||
(
|
||||
'sending',
|
||||
['sending']
|
||||
),
|
||||
(
|
||||
'delivered',
|
||||
['delivered']
|
||||
),
|
||||
(
|
||||
'failed',
|
||||
['failed', 'temporary-failure', 'permanent-failure', 'technical-failure']
|
||||
)
|
||||
]
|
||||
)
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_should_show_page_for_one_job(
|
||||
app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_service_template,
|
||||
mock_get_service_statistics,
|
||||
mock_get_job,
|
||||
mocker,
|
||||
mock_get_notifications,
|
||||
fake_uuid
|
||||
fake_uuid,
|
||||
status_argument,
|
||||
expected_api_call
|
||||
):
|
||||
file_name = mock_get_job(service_one['id'], fake_uuid)['data']['original_file_name']
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
response = client.get(url_for('main.view_job', service_id=service_one['id'], job_id=fake_uuid))
|
||||
response = client.get(url_for(
|
||||
'main.view_job',
|
||||
service_id=service_one['id'],
|
||||
job_id=fake_uuid,
|
||||
status=status_argument
|
||||
))
|
||||
|
||||
assert response.status_code == 200
|
||||
content = response.get_data(as_text=True)
|
||||
@@ -49,6 +81,22 @@ def test_should_show_page_for_one_job(
|
||||
assert file_name in content
|
||||
assert 'Delivered' in content
|
||||
assert '11:10' in content
|
||||
assert url_for(
|
||||
'main.view_job_updates',
|
||||
service_id=service_one['id'],
|
||||
job_id=fake_uuid,
|
||||
status=status_argument,
|
||||
) in content
|
||||
assert url_for(
|
||||
'main.view_job_csv',
|
||||
service_id=service_one['id'],
|
||||
job_id=fake_uuid
|
||||
) in content
|
||||
mock_get_notifications.assert_called_with(
|
||||
service_one['id'],
|
||||
fake_uuid,
|
||||
status=expected_api_call
|
||||
)
|
||||
|
||||
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
@@ -57,6 +105,7 @@ def test_should_show_updates_for_one_job_as_json(
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_notifications,
|
||||
mock_get_service_statistics,
|
||||
mock_get_job,
|
||||
mocker,
|
||||
fake_uuid
|
||||
@@ -112,6 +161,7 @@ def test_can_show_notifications(
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_notifications,
|
||||
mock_get_service_statistics,
|
||||
mocker,
|
||||
message_type,
|
||||
page_title,
|
||||
@@ -166,11 +216,14 @@ def test_can_show_notifications(
|
||||
assert 'text/csv' in csv_response.headers['Content-Type']
|
||||
|
||||
|
||||
def test_should_show_notifications_for_a_service_with_next_previous(app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_notifications_with_previous_next,
|
||||
mocker):
|
||||
def test_should_show_notifications_for_a_service_with_next_previous(
|
||||
app_,
|
||||
service_one,
|
||||
active_user_with_permissions,
|
||||
mock_get_notifications_with_previous_next,
|
||||
mock_get_service_statistics,
|
||||
mocker
|
||||
):
|
||||
with app_.test_request_context():
|
||||
with app_.test_client() as client:
|
||||
client.login(active_user_with_permissions, mocker, service_one)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from app.statistics_utils import sum_of_statistics, add_rates_to
|
||||
from app.statistics_utils import sum_of_statistics, add_rates_to, statistics_by_state
|
||||
|
||||
|
||||
@pytest.mark.parametrize('delivery_statistics', [
|
||||
@@ -96,3 +96,20 @@ def test_add_rates_keeps_original_raw_data():
|
||||
assert resp['emails_requested'] == 2
|
||||
assert resp['sms_failed'] == 3
|
||||
assert resp['sms_requested'] == 4
|
||||
|
||||
|
||||
def test_service_statistics_by_state():
|
||||
resp = statistics_by_state({
|
||||
'emails_requested': 3,
|
||||
'emails_failed': 1,
|
||||
'emails_delivered': 1,
|
||||
'sms_requested': 3,
|
||||
'sms_failed': 1,
|
||||
'sms_delivered': 1
|
||||
})
|
||||
|
||||
for message_type in ['email', 'sms']:
|
||||
assert resp[message_type]['processed'] == 3
|
||||
assert resp[message_type]['sending'] == 1
|
||||
assert resp[message_type]['delivered'] == 1
|
||||
assert resp[message_type]['failed'] == 1
|
||||
|
||||
Reference in New Issue
Block a user