From d1d13c23c5f31713a7aa46dbfe39ff7463827f93 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 20 Mar 2017 17:35:01 +0000 Subject: [PATCH] Fix broken links on template statistics page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests assumed that the API returns the template `id` as part of the object. It doesn’t – it returns it as the key used to look up the object. The `id` was missing from the transformation into the format used by the front end. For some reason Flask is fine building the URL with `template_id=None`, but obviously this doesn’t generate a valid link. --- app/main/views/dashboard.py | 1 + tests/app/main/views/test_dashboard.py | 2 ++ tests/conftest.py | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index c3000324e..e7a18fe33 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -321,6 +321,7 @@ def format_template_stats_to_list(stats_dict): template['counts'].get(status, 0) for status in REQUESTED_STATUSES ), + id=template_id, **template ) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 2d964e2c5..ec1eb7b5f 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -649,11 +649,13 @@ def test_format_template_stats_to_list(): 'counts': counts, 'name': 'foo', 'requested_count': 7, + 'id': 'template_1_id', } in stats_list assert { 'counts': {}, 'name': 'bar', 'requested_count': 0, + 'id': 'template_2_id', } in stats_list diff --git a/tests/conftest.py b/tests/conftest.py index c9c4d1c63..b622768e2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1289,7 +1289,6 @@ def mock_get_monthly_template_statistics(mocker, service_one, fake_uuid): }, "name": 'My first template', "type": 'sms', - "id": fake_uuid, } } }