Merge pull request #405 from alphagov/add-date-back-into-template-stats

Add date field back into template stats
This commit is contained in:
Adam Shimali
2016-04-06 15:15:44 +01:00
2 changed files with 26 additions and 14 deletions

View File

@@ -3,7 +3,7 @@
template_statistics,
caption="Recent templates used",
empty_message='You havent sent any batch messages yet',
field_headings=['Template', 'Type', right_aligned_field_heading('Usage')]
field_headings=['Template', 'Type', 'Date', right_aligned_field_heading('Usage')]
) %}
{% call field() %}
<a href="{{ url_for('.edit_service_template', service_id=current_service.id, template_id=item.template.id) }}">
@@ -13,7 +13,10 @@
{% call field() %}
{{item.template.template_type}}
{% endcall %}
{% call field(align='right') %}
{% call field() %}
{{item.day|format_date}}
{% endcall %}
{% call field(align='right') %}
{{ item.usage_count }}
{% endcall %}
{% endcall %}

View File

@@ -1,20 +1,22 @@
from flask import url_for
from bs4 import BeautifulSoup
from tests import validate_route_permission
from tests.conftest import SERVICE_ONE_ID
def test_should_show_recent_jobs_on_dashboard(app_,
api_user_active,
mock_get_service,
mock_get_service_templates,
mock_get_service_statistics,
mock_get_template_statistics,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_jobs,
mock_has_permissions):
def test_should_show_recent_templates_on_dashboard(app_,
api_user_active,
mock_get_service,
mock_get_service_templates,
mock_get_service_statistics,
mock_get_template_statistics,
mock_get_user,
mock_get_user_by_email,
mock_login,
mock_get_jobs,
mock_has_permissions):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -22,10 +24,17 @@ def test_should_show_recent_jobs_on_dashboard(app_,
assert response.status_code == 200
text = response.get_data(as_text=True)
assert 'Test Service' in text
mock_get_service_statistics.assert_called_once_with(SERVICE_ONE_ID)
mock_get_template_statistics.assert_called_once_with(SERVICE_ONE_ID)
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
headers = [header.text.strip() for header in page.find_all('h2')]
assert 'Test Service' in headers
assert 'Sent today' in headers
template_usage_headers = [th.text.strip() for th in page.thead.find_all('th')]
for th in ['Template', 'Type', 'Date', 'Usage']:
assert th in template_usage_headers
def _test_dashboard_menu(mocker, app_, usr, service, permissions):
with app_.test_request_context():