def test_assessment_is_up_to_date_assessment_before_starting_probation(self): supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', state_code='US_ID', custodial_authority='US_ID_DOC', start_date=date(2018, 3, 5), admission_reason=StateSupervisionPeriodAdmissionReason.COURT_SENTENCE, supervision_period_supervision_type=StateSupervisionPeriodSupervisionType.PROBATION ) assessment = StateAssessment.new_with_defaults( state_code='US_ID', assessment_type=StateAssessmentType.LSIR, assessment_score=33, assessment_level=StateAssessmentLevel.HIGH, assessment_date=date(2018, 1, 3) ) # This person started on probation more than NEW_SUPERVISION_ASSESSMENT_DEADLINE_DAYS ago, and they do not have # a recent assessment, so their assessment is not in compliance start_of_supervision = supervision_period.start_date - \ relativedelta(days=NEW_SUPERVISION_ASSESSMENT_DEADLINE_DAYS) compliance_evaluation_date = supervision_period.start_date + \ relativedelta(days=1) assessment_up_to_date = _assessment_is_up_to_date( supervision_period, start_of_supervision, compliance_evaluation_date, most_recent_assessment=assessment ) self.assertTrue(assessment_up_to_date)
def test_assessment_is_up_to_date(self): supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', state_code='US_ID', custodial_authority='US_ID_DOC', start_date=date(2018, 3, 5), termination_date=date(2018, 5, 19), admission_reason=StateSupervisionPeriodAdmissionReason.COURT_SENTENCE, termination_reason=StateSupervisionPeriodTerminationReason.DISCHARGE, supervision_period_supervision_type=StateSupervisionPeriodSupervisionType.PROBATION ) assessment = StateAssessment.new_with_defaults( state_code='US_ID', assessment_type=StateAssessmentType.LSIR, assessment_score=33, assessment_level=StateAssessmentLevel.HIGH, assessment_date=date(2018, 3, 10) ) start_of_supervision = supervision_period.start_date compliance_evaluation_date = date(2018, 4, 30) assessment_up_to_date = _assessment_is_up_to_date( supervision_period, start_of_supervision, compliance_evaluation_date, assessment ) self.assertTrue(assessment_up_to_date)
def test_assessment_is_up_to_date_no_assessment_old_period(self): supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', state_code='US_ID', custodial_authority='US_ID_DOC', start_date=date(2018, 3, 5), admission_reason=StateSupervisionPeriodAdmissionReason.TRANSFER_WITHIN_STATE, supervision_period_supervision_type=StateSupervisionPeriodSupervisionType.PROBATION ) # This person started on probation more than NEW_SUPERVISION_ASSESSMENT_DEADLINE_DAYS ago, and they do not have # a recent assessment, so their assessment is not in compliance start_of_supervision = supervision_period.start_date - \ relativedelta(days=NEW_SUPERVISION_ASSESSMENT_DEADLINE_DAYS) compliance_evaluation_date = supervision_period.start_date + \ relativedelta(days=1) assessment_up_to_date = _assessment_is_up_to_date( supervision_period, start_of_supervision, compliance_evaluation_date, most_recent_assessment=None ) self.assertFalse(assessment_up_to_date)
def test_assessment_is_up_to_date_no_assessment_new_period(self): supervision_period = \ StateSupervisionPeriod.new_with_defaults( supervision_period_id=111, external_id='sp1', state_code='US_ID', custodial_authority='US_ID_DOC', start_date=date(2018, 3, 5), admission_reason=StateSupervisionPeriodAdmissionReason.COURT_SENTENCE, supervision_period_supervision_type=StateSupervisionPeriodSupervisionType.PROBATION ) start_of_supervision = supervision_period.start_date compliance_evaluation_date = supervision_period.start_date + \ relativedelta(days=1) assessment_up_to_date = _assessment_is_up_to_date( supervision_period, start_of_supervision, compliance_evaluation_date, most_recent_assessment=None) self.assertTrue(assessment_up_to_date)