def test_get_month_supervision_type_no_sentences_internal_unknown(self): any_date_in_month = date(2018, 4, 13) supervision_period = StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id="sp1", status=StateSupervisionPeriodStatus.TERMINATED, state_code="US_XX", start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason. DISCHARGE, supervision_type=None, ) supervision_sentences = [] incarceration_sentences = [] supervision_type = get_month_supervision_type( any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period, ) self.assertEqual( StateSupervisionPeriodSupervisionType.INTERNAL_UNKNOWN, supervision_type)
def test_get_month_supervision_type_no_dates_on_sentence(self): any_date_in_month = date(2018, 4, 13) supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', status=StateSupervisionPeriodStatus.TERMINATED, state_code='US_ND', start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason.DISCHARGE, supervision_type=None ) supervision_sentence = \ StateSupervisionSentence.new_with_defaults( supervision_sentence_id=111, external_id='ss1', status=StateSentenceStatus.COMPLETED, supervision_periods=[supervision_period] ) supervision_sentences = [supervision_sentence] incarceration_sentences = [] supervision_type = get_month_supervision_type(any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period) self.assertEqual( StateSupervisionPeriodSupervisionType.INTERNAL_UNKNOWN, supervision_type)
def test_get_month_supervision_type_parole(self): any_date_in_month = date(2018, 4, 13) supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', status=StateSupervisionPeriodStatus.TERMINATED, state_code='US_ND', start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason.DISCHARGE, supervision_type=None ) incarceration_sentence = StateIncarcerationSentence.new_with_defaults( incarceration_sentence_id=123, external_id='is1', start_date=date(2018, 3, 1), completion_date=date(2018, 5, 30), supervision_periods=[supervision_period]) supervision_sentences = [] incarceration_sentences = [incarceration_sentence] supervision_type = get_month_supervision_type(any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period) self.assertEqual(StateSupervisionPeriodSupervisionType.PAROLE, supervision_type)
def test_get_month_supervision_type_dual(self): any_date_in_month = date(2018, 4, 13) supervision_period = StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id="sp1", status=StateSupervisionPeriodStatus.TERMINATED, state_code="US_XX", start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason. DISCHARGE, supervision_type=None, ) supervision_sentence = StateSupervisionSentence.new_with_defaults( state_code="US_XX", supervision_sentence_id=111, external_id="ss1", start_date=date(2018, 3, 1), completion_date=date(2018, 5, 30), status=StateSentenceStatus.COMPLETED, projected_completion_date=date(2018, 5, 19), supervision_type=StateSupervisionType.PROBATION, supervision_periods=[supervision_period], ) incarceration_sentence = StateIncarcerationSentence.new_with_defaults( state_code="US_XX", incarceration_sentence_id=123, external_id="is1", start_date=date(2018, 3, 1), completion_date=date(2018, 5, 30), supervision_periods=[supervision_period], status=StateSentenceStatus.PRESENT_WITHOUT_INFO, ) supervision_sentences = [supervision_sentence] incarceration_sentences = [incarceration_sentence] supervision_type = get_month_supervision_type( any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period, ) self.assertEqual(StateSupervisionPeriodSupervisionType.DUAL, supervision_type)
def test_get_month_supervision_type_probation_options(self): any_date_in_month = date(2018, 4, 13) supervision_period = StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id="sp1", status=StateSupervisionPeriodStatus.TERMINATED, state_code="US_XX", start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason. DISCHARGE, supervision_type=None, ) supervision_sentence = StateSupervisionSentence.new_with_defaults( state_code="US_XX", supervision_sentence_id=111, external_id="ss1", start_date=date(2018, 3, 1), completion_date=date(2018, 5, 30), status=StateSentenceStatus.COMPLETED, projected_completion_date=date(2018, 5, 19), supervision_periods=[supervision_period], ) supervision_sentences = [supervision_sentence] incarceration_sentences = [] probation_types = [ StateSupervisionType.PRE_CONFINEMENT, StateSupervisionType.POST_CONFINEMENT, StateSupervisionType.HALFWAY_HOUSE, StateSupervisionType.CIVIL_COMMITMENT, ] for sup_type in probation_types: supervision_sentence.supervision_type = sup_type supervision_type = get_month_supervision_type( any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period, ) self.assertEqual(StateSupervisionPeriodSupervisionType.PROBATION, supervision_type)
def test_get_month_supervision_type_started_and_completed_on_end_of_month( self): any_date_in_month = date(2018, 4, 13) supervision_period = StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id="sp1", status=StateSupervisionPeriodStatus.TERMINATED, state_code="US_XX", start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason. DISCHARGE, supervision_type=None, ) supervision_sentence = StateSupervisionSentence.new_with_defaults( state_code="US_XX", supervision_sentence_id=111, external_id="ss1", start_date=date(2018, 4, 30), completion_date=date(2018, 4, 30), status=StateSentenceStatus.COMPLETED, supervision_type=StateSupervisionType.PAROLE, projected_completion_date=date(2018, 5, 19), supervision_periods=[supervision_period], ) supervision_sentences = [supervision_sentence] incarceration_sentences = [] supervision_type = get_month_supervision_type( any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period, ) self.assertEqual(StateSupervisionPeriodSupervisionType.PAROLE, supervision_type)
def test_get_month_supervision_type_test_all_enums(self): any_date_in_month = date(2018, 4, 13) supervision_period = StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id="sp1", status=StateSupervisionPeriodStatus.TERMINATED, state_code="US_XX", start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), termination_reason=StateSupervisionPeriodTerminationReason. DISCHARGE, supervision_type=None, ) supervision_sentence = StateSupervisionSentence.new_with_defaults( state_code="US_XX", supervision_sentence_id=111, external_id="ss1", start_date=date(2018, 3, 1), completion_date=date(2018, 5, 30), status=StateSentenceStatus.COMPLETED, projected_completion_date=date(2018, 5, 19), supervision_type=StateSupervisionType.INTERNAL_UNKNOWN, supervision_periods=[supervision_period], ) supervision_sentences = [supervision_sentence] incarceration_sentences = [] for sup_type in StateSupervisionType: supervision_sentence.supervision_type = sup_type # Tests that all cases are covered _ = get_month_supervision_type( any_date_in_month, supervision_sentences, incarceration_sentences, supervision_period, )