From d2f976c8eececffa5d6d9c5e466091ffd91527d5 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 30 Dec 2019 16:25:09 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20progress=20once=20notifi?= =?UTF-8?q?cations=20are=20gone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We work out how complete a job’s processing is by looking at how many notifications have been created. Later, we deleted all the notifications, according to the data retention schedule. This makes it look like the job has gone back to 0% processed. This commit accounts for this by not showing the % complete message once a finished job has had its notifications deleted. --- .../partials/jobs/notifications.html | 2 +- tests/app/main/views/test_jobs.py | 21 +++++++++++++++++++ tests/conftest.py | 3 ++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/templates/partials/jobs/notifications.html b/app/templates/partials/jobs/notifications.html index 7ff70cc7f..b11b396cb 100644 --- a/app/templates/partials/jobs/notifications.html +++ b/app/templates/partials/jobs/notifications.html @@ -28,7 +28,7 @@ {% if template.template_type == 'letter' %}
{% endif %} - {% if percentage_complete < 100 %} + {% if percentage_complete < 100 and job.job_status != 'finished' %}

Report is {{ "{:.0f}%".format(percentage_complete * 0.99) }} complete…

diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 477794706..fe68a16b9 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -317,6 +317,27 @@ def test_should_show_job_without_notifications( assert page.select_one('tbody').text.strip() == 'No messages to show' +def test_should_show_old_job( + client_request, + service_one, + active_user_with_permissions, + mock_get_service_template, + mock_get_job, + mocker, + mock_get_notifications_with_no_notifications, + mock_get_service_data_retention, + fake_uuid, +): + page = client_request.get( + 'main.view_job', + service_id=service_one['id'], + job_id=fake_uuid, + ) + assert not page.select('p.hint') + assert not page.select('a[download]') + assert page.select_one('tbody').text.strip() == 'No messages to show' + + @freeze_time("2016-01-01 11:09:00.061258") def test_should_show_letter_job( client_request, diff --git a/tests/conftest.py b/tests/conftest.py index c5e4b371f..d99f974fc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1818,7 +1818,8 @@ def mock_get_job_in_progress(mocker, api_user_active): return {"data": job_json( service_id, api_user_active, job_id=job_id, notification_count=10, - notifications_requested=5 + notifications_requested=5, + job_status='processing', )} return mocker.patch('app.job_api_client.get_job', side_effect=_get_job)