diff options
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() |