add stats boxes to platform admin page

moved a couple of stats summary functions from dashboard to a shared statistics_utils file
This commit is contained in:
Leo Hemsted
2016-05-25 16:51:09 +01:00
parent 6d43067688
commit 83b151982e
7 changed files with 128 additions and 52 deletions

View File

@@ -1,7 +1,12 @@
from datetime import date
from flask import url_for
from freezegun import freeze_time
from tests.conftest import mock_get_user
from app.main.views.platform_admin import get_global_stats
def test_should_redirect_if_not_logged_in(app_):
with app_.test_request_context():
@@ -22,7 +27,7 @@ def test_should_403_if_not_platform_admin(app_, active_user_with_permissions, mo
assert response.status_code == 403
def test_should_render_platform_admin_page(app_, platform_admin_user, mocker):
def test_should_render_platform_admin_page(app_, platform_admin_user, mocker, mock_get_all_service_statistics):
with app_.test_request_context():
with app_.test_client() as client:
mock_get_user(mocker, user=platform_admin_user)
@@ -34,3 +39,21 @@ def test_should_render_platform_admin_page(app_, platform_admin_user, mocker):
assert 'Platform admin' in resp_data
assert 'List all services' in resp_data
assert 'View providers' in resp_data
def test_get_global_stats_should_summarise_all_stats(mock_get_all_service_statistics):
resp = get_global_stats()
assert 'emails_delivered' in resp
assert 'emails_failed' in resp
assert 'emails_failure_rate' in resp
assert 'sms_delivered' in resp
assert 'sms_failed' in resp
assert 'sms_failure_rate' in resp
@freeze_time('2000-06-30T23:30:00', tz_offset=0)
def test_get_global_stats_should_query_for_today_forced_to_GMT(mock_get_all_service_statistics):
get_global_stats()
mock_get_all_service_statistics.assert_called_once_with(date(2000, 7, 1))