diff options
author | Matthew Lemon <y@yulqen.org> | 2024-10-07 15:40:13 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-10-14 14:35:17 +0100 |
commit | 46e5ae3428a15980f4721074aef8a499e64c0dcf (patch) | |
tree | eddb5ecc6723c541eae6348e0ce1380670d7f566 /engagements/tests/test_views.py | |
parent | f7fd378a421a18026f55f566d2119ba05e41becb (diff) |
Nice engagement duration text for summary box on detail page
Diffstat (limited to 'engagements/tests/test_views.py')
-rw-r--r-- | engagements/tests/test_views.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/engagements/tests/test_views.py b/engagements/tests/test_views.py index 017b96f..01d73c7 100644 --- a/engagements/tests/test_views.py +++ b/engagements/tests/test_views.py @@ -6,12 +6,41 @@ from django.test import RequestFactory from django.urls import reverse from engagements import models, views -from engagements.models import EngagementStrategy, RegulatoryCycle, Organisation -from engagements.utils import populate_database +from engagements.models import EngagementStrategy, Organisation, RegulatoryCycle +from engagements.utils import duration_formatter, populate_database pytestmark = pytest.mark.django_db +def test_single_day_string(): + """test date formatting for the summary box on the detail page""" + d1 = datetime.date(2024, 10, 10) + d2 = datetime.date(2024, 10, 10) + duration_str = duration_formatter(d1, d2) + assert duration_str == "10 October 2024 (1 day)" + +def test_multi_duration_string(): + """test date formatting for the summary box on the detail page""" + d1 = datetime.date(2024, 10, 10) + d2 = datetime.date(2024, 10, 12) + duration_str = duration_formatter(d1, d2) + assert duration_str == "10-12 October 2024 (3 days)" + +def test_multi_duration_string_longer(): + """test date formatting for the summary box on the detail page""" + d1 = datetime.date(2024, 10, 1) + d2 = datetime.date(2024, 10, 12) + duration_str = duration_formatter(d1, d2) + assert duration_str == "01-12 October 2024 (12 days)" + +def test_multi_duration_over_month_boundary_string(): + """test date formatting for the summary box on the detail page""" + d1 = datetime.date(2024, 9, 30) + d2 = datetime.date(2024, 10, 1) + duration_str = duration_formatter(d1, d2) + assert duration_str == "30 September - 01 October 2024 (2 days)" + + @pytest.fixture def test_data(): return populate_database() |