11from datetime import datetime , timedelta
22
33import holidays
4+ import pytest
45
56from netsgiro .utils import OSLO_TZ , get_minimum_due_date
7+ from netsgiro .validators import validate_due_date
68
79monday = datetime (2022 , 3 , 28 , 13 , 59 , tzinfo = OSLO_TZ )
810
@@ -24,8 +26,8 @@ def test_minimum_due_date_after_cutoff():
2426 generated after 14:00 Norwegian time should be adjusted by 5 days.
2527 """
2628 assert (
27- get_minimum_due_date (monday_after_cutoff )
28- == (monday_after_cutoff + timedelta (days = 5 )).date ()
29+ get_minimum_due_date (monday_after_cutoff )
30+ == (monday_after_cutoff + timedelta (days = 5 )).date ()
2931 )
3032
3133
@@ -49,8 +51,8 @@ def test_minimum_due_date_with_holidays_after_cutoff():
4951 holidays is upped to 3, so we expect 2 more days of offsetting.
5052 """
5153 assert (
52- get_minimum_due_date (day_before_easter_after_cutoff )
53- == (day_before_easter_after_cutoff + timedelta (days = 8 )).date ()
54+ get_minimum_due_date (day_before_easter_after_cutoff )
55+ == (day_before_easter_after_cutoff + timedelta (days = 8 )).date ()
5456 )
5557
5658
@@ -70,3 +72,11 @@ def test_minimum_due_date_without_holiday_dependency():
7072 sys .modules ['holidays' ] = None
7173 assert get_minimum_due_date (monday ) == (monday + timedelta (days = 4 )).date ()
7274 sys .modules ['holidays' ] = holidays
75+
76+
77+ def test_validate_due_date ():
78+ with pytest .raises (ValueError , match = 'The minimum due date of a transaction' ):
79+ validate_due_date (datetime .now ().date ())
80+
81+ with pytest .raises (ValueError , match = 'The maximum due date of a transaction' ):
82+ validate_due_date ((datetime .now () + timedelta (days = 366 )).date ())
0 commit comments