Skip to content

Commit b5e9c7f

Browse files
committed
Add test for gregorian converter to version control
1 parent 7af0628 commit b5e9c7f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from undate.converters.calendars import GregorianDateConverter
2+
3+
4+
class TestGregorianDateConverter:
5+
def test_to_gregorian(self):
6+
converter = GregorianDateConverter()
7+
# conversion is a no-op, returns values unchanged
8+
assert converter.to_gregorian(2025, 6, 15) == (2025, 6, 15)
9+
10+
def test_min_month(self):
11+
assert GregorianDateConverter().min_month() == 1
12+
13+
def test_max_month(self):
14+
assert GregorianDateConverter().max_month(2025) == 12
15+
16+
# todo: test max day
17+
#
18+
def test_representative_years(self):
19+
converter = GregorianDateConverter()
20+
# single year is not filtered
21+
assert converter.representative_years([2025]) == [2025]
22+
# multiple non-leap years, returns just the first
23+
assert converter.representative_years([2025, 2026]) == [2025]
24+
# next leap year is 2028; returns first leap year and first non-leap year, in input order
25+
assert converter.representative_years([2025, 2026, 2028, 2029]) == [2025, 2028]
26+
27+
# if no years are provided, returns a known leap year and non-leap years
28+
assert converter.representative_years() == [
29+
converter.LEAP_YEAR,
30+
converter.NON_LEAP_YEAR,
31+
]
32+
assert converter.representative_years([]) == [
33+
converter.LEAP_YEAR,
34+
converter.NON_LEAP_YEAR,
35+
]

0 commit comments

Comments
 (0)