11"""
22Test templatetags of common app
33"""
4+
45from datetime import date , datetime , timezone
56
67import pytest
78
89from ..templatetags .common_tags import (
910 amp_date ,
11+ amp_date_trunc ,
1012 amp_datetime ,
13+ amp_datetime_short_month ,
1114 list_item_by_index ,
1215 markdown_to_html ,
1316)
@@ -59,6 +62,18 @@ def test_amp_date(date_to_format, expected_result):
5962 assert amp_date (date_to_format ) == expected_result
6063
6164
65+ @pytest .mark .parametrize (
66+ "date_to_format,expected_result" ,
67+ [
68+ (date (2021 , 4 , 1 ), "1 Apr 2021" ),
69+ (None , "" ),
70+ ],
71+ )
72+ def test_amp_date_trunc (date_to_format , expected_result ):
73+ """Test date formatted according to GDS style guide."""
74+ assert amp_date_trunc (date_to_format ) == expected_result
75+
76+
6277@pytest .mark .parametrize (
6378 "datetime_to_format,expected_result" ,
6479 [
@@ -70,3 +85,16 @@ def test_amp_date(date_to_format, expected_result):
7085def test_amp_datetime (datetime_to_format , expected_result ):
7186 """Test date and time formatted according to GDS style guide."""
7287 assert amp_datetime (datetime_to_format ) == expected_result
88+
89+
90+ @pytest .mark .parametrize (
91+ "datetime_to_format,expected_result" ,
92+ [
93+ (datetime (2021 , 1 , 4 , 9 , 1 , 0 , 0 , timezone .utc ), "4 Jan 2021 9:01am" ),
94+ (datetime (2021 , 7 , 4 , 8 , 1 , 0 , 0 , timezone .utc ), "4 Jul 2021 9:01am" ),
95+ (None , "" ),
96+ ],
97+ )
98+ def test_amp_datetime_short_month (datetime_to_format , expected_result ):
99+ """Test date and time formatted according to GDS style guide."""
100+ assert amp_datetime_short_month (datetime_to_format ) == expected_result
0 commit comments