Skip to content

Commit

Permalink
Display item count and add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpepper-trade committed Mar 18, 2024
1 parent 41377ca commit 0b3bdce
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
13 changes: 11 additions & 2 deletions measures/jinja2/includes/measures/create-task-list.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

{% for object in object_list %}
{% set workbasket_link -%}
<a class="govuk-link" href="{{ url("workbaskets:workbasket-ui-detail", kwargs={"pk": object.workbasket.pk}) }}">{{ object.workbasket.pk }}</a>
<a
class="govuk-link"
href="{{ url("workbaskets:workbasket-ui-detail", kwargs={"pk": object.workbasket.pk}) }}"
>{{ object.workbasket.pk }}</a>
{%- endset %}

{% set submitted_date -%}
Expand All @@ -22,6 +25,12 @@
</span>
{%- endset %}

{% set item_count -%}
<span class="processed-count">
{{ object.successfully_processed_count }} of {{ object.expected_measures_count }} processed
</span>
{%- endset %}

{% set action_html -%}
{%- if is_task_failed(object) %}
<span class="contact-tap">Contact TAP</span>
Expand All @@ -40,7 +49,7 @@
{"text": submitted_date},
{"text": submitted_by},
{"text": object_status},
{"text": "TODO"},
{"text": item_count},
{"text": action_html},
]) or "" }}
{% endfor %}
Expand Down
37 changes: 37 additions & 0 deletions measures/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import date
from decimal import Decimal
from typing import OrderedDict
from unittest.mock import PropertyMock
from unittest.mock import patch
from urllib.parse import urlencode

Expand Down Expand Up @@ -2804,6 +2805,42 @@ def test_measures_create_process_queue_view_task_action_options(
assert page.find("span", class_="not-applicable")


@pytest.mark.parametrize(
("expected_measures_count", "successfully_processed_count"),
(
(1, 0),
(1, 1),
),
)
def test_measures_create_process_queue_view_processed_count(
expected_measures_count,
successfully_processed_count,
valid_user_client,
):
"""Test that the item count column displays the correct values for different
states."""

MeasuresBulkCreatorFactory.create(
successfully_processed_count=successfully_processed_count,
)
url = reverse("measure-create-process-queue")

with patch(
"measures.models.bulk_processing.MeasuresBulkCreator.expected_measures_count",
new_callable=PropertyMock,
) as mock_expected_measures_count:
mock_expected_measures_count.return_value = expected_measures_count
response = valid_user_client.get(url)

assert response.status_code == 200

page = BeautifulSoup(response.content.decode(response.charset), "html.parser")
processed_count = page.find("span", class_="processed-count")
expected_substring = f"{successfully_processed_count} of {expected_measures_count}"

assert expected_substring in processed_count.text


def test_measures_create_process_queue_view_task_is_failed(
valid_user_client,
session_request_with_workbasket,
Expand Down

0 comments on commit 0b3bdce

Please sign in to comment.