def test_find_most_recently_terminated_supervision_period_starts_on_admission_date( self): supervision_period_recent = StateSupervisionPeriod.new_with_defaults( start_date=date(2006, 1, 1), termination_date=date(2007, 12, 31)) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(2006, 1, 1), supervision_periods=[supervision_period_recent]) self.assertIsNone(most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_month_boundary( self): supervision_period = StateSupervisionPeriod.new_with_defaults( start_date=date(2000, 1, 1), termination_date=date(2005, 3, 31)) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(2005, 4, 1), supervision_periods=[supervision_period]) self.assertEqual(supervision_period, most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_none(self): supervision_period_older = StateSupervisionPeriod.new_with_defaults( start_date=date(2000, 1, 1), termination_date=date(2005, 1, 1)) supervision_period_recent = StateSupervisionPeriod.new_with_defaults( start_date=date(2006, 3, 1), termination_date=date(2010, 1, 1)) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(1990, 10, 1), supervision_periods=[ supervision_period_older, supervision_period_recent ]) self.assertIsNone(most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_overlapping_no_termination( self): supervision_period_older = StateSupervisionPeriod.new_with_defaults( start_date=date(2000, 1, 1), termination_date=date(2007, 9, 20)) # Overlapping supervision period that should have been found in the other identifier code supervision_period_recent = StateSupervisionPeriod.new_with_defaults( start_date=date(2006, 3, 1), ) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(2007, 10, 1), supervision_periods=[ supervision_period_older, supervision_period_recent ]) self.assertEqual(supervision_period_older, most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_overlapping( self): supervision_period_older = StateSupervisionPeriod.new_with_defaults( start_date=date(2000, 1, 1), termination_date=date(2007, 9, 20)) # Overlapping supervision period should not be returned supervision_period_recent = StateSupervisionPeriod.new_with_defaults( start_date=date(2006, 3, 1), termination_date=date(2010, 1, 1)) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(2007, 10, 1), supervision_periods=[ supervision_period_older, supervision_period_recent ]) self.assertEqual(supervision_period_older, most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_ends_on_cutoff_date( self): supervision_period_older = StateSupervisionPeriod.new_with_defaults( start_date=date(2000, 1, 1), termination_date=date(2005, 1, 1)) supervision_period_recent = StateSupervisionPeriod.new_with_defaults( start_date=date(2006, 3, 1), termination_date=date(2010, 1, 1)) # Set the admission date to be on the last day of the cut-off for how close a supervision period termination # has to be to a revocation admission to be counted as a proximal supervision period admission_date = ( supervision_period_recent.termination_date + relativedelta(days=SUPERVISION_PERIOD_PROXIMITY_DAY_LIMIT)) most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=admission_date, supervision_periods=[ supervision_period_older, supervision_period_recent ]) self.assertEqual(supervision_period_recent, most_recently_terminated_period)
def test_find_most_recently_terminated_supervision_period_no_periods(self): most_recently_terminated_period = _find_last_supervision_period_terminated_before_date( upper_bound_date=date(1990, 10, 1), supervision_periods=[]) self.assertIsNone(most_recently_terminated_period)