Skip to content

Commit

Permalink
add test clean method of suspensions
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Dec 2, 2021
1 parent d0bfb8f commit e668bc7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions itou/approvals/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,30 @@ class SuspensionModelTest(TestCase):
Test Suspension model.
"""

def test_clean(self):
today = timezone.now().date()
start_at = timezone.now().date() - relativedelta(months=2)
end_at = start_at + relativedelta(months=2)
approval = ApprovalFactory(start_at=start_at, end_at=end_at)
suspension = SuspensionFactory(approval=approval)

# test the when suspension is out of boundaries
suspension.start_at = start_at - relativedelta(months=1)
with self.assertRaises(ValidationError):
suspension.clean()

# the case when end_at < start_at
suspension.start_at = start_at
suspension.end_at = start_at - relativedelta(months=1)
with self.assertRaises(ValidationError):
suspension.clean()

# declare suspension in the future
suspension.start_at = today + relativedelta(days=2)
suspension.end_at = end_at
with self.assertRaises(ValidationError):
suspension.clean()

def test_duration(self):
expected_duration = datetime.timedelta(days=2)
start_at = timezone.now().date()
Expand Down

0 comments on commit e668bc7

Please sign in to comment.