Esempio n. 1
0
    def test_guidelines_applicable_for_case_interstate_compact(self):
        """The guidelines should not be applicable to people who are in interstate compact."""
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            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,
            supervision_level=StateSupervisionLevel.INTERSTATE_COMPACT,
            supervision_level_raw_text="9",
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=supervision_period.start_date,
            assessments=[],
            supervision_contacts=[],
        )

        applicable = us_nd_supervision_compliance._guidelines_applicable_for_case(
        )

        self.assertFalse(applicable)
    def test_guidelines_applicable_for_case_invalid_supervision_case_type(
            self) -> None:
        """The guidelines should not be applicable to a case type that is not GENERAL or SEX_OFFENSE."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=StateSupervisionLevel.HIGH,
            supervision_level_raw_text="SO HIGH",
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.SERIOUS_MENTAL_ILLNESS,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=[],
        )

        applicable = us_nd_supervision_compliance._guidelines_applicable_for_case(
            start_of_supervision)

        self.assertFalse(applicable)
    def test_guidelines_applicable_for_case(self) -> None:
        """The guidelines should be applicable to people who are not in interstate compact or not classified."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=StateSupervisionLevel.MEDIUM,
            supervision_level_raw_text="2",
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=[],
        )

        applicable = us_nd_supervision_compliance._guidelines_applicable_for_case(
            start_of_supervision)

        self.assertTrue(applicable)
    def test_home_visit_frequency_sufficient_medium_level(self, ) -> None:
        """Tests home visit frequency for medium level"""
        contact_1 = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 3, 8),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
            location=StateSupervisionContactLocation.RESIDENCE,
        )
        contact_2 = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2019, 3, 6),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
            location=StateSupervisionContactLocation.RESIDENCE,
        )

        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=StateSupervisionLevel.MEDIUM,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        supervision_contacts = [contact_1, contact_2]

        evaluation_date = start_of_supervision + relativedelta(days=375)

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        home_visit_frequency_sufficient = (
            us_nd_supervision_compliance._home_visit_frequency_is_sufficient(
                evaluation_date))

        self.assertTrue(home_visit_frequency_sufficient)
def get_state_specific_case_compliance_manager(
    supervision_period: StateSupervisionPeriod,
    case_type: StateSupervisionCaseType,
    start_of_supervision: date,
    assessments: List[StateAssessment],
    supervision_contacts: List[StateSupervisionContact],
) -> Optional[StateSupervisionCaseComplianceManager]:
    """Returns a state-specific SupervisionCaseComplianceManager object, containing information about whether the
    given supervision case is in compliance with state-specific standards. If the state of the
    supervision_period does not have state-specific compliance calculations, returns None."""
    state_code = supervision_period.state_code.upper()
    if state_code == StateCode.US_ID.value:
        return UsIdSupervisionCaseCompliance(
            supervision_period,
            case_type,
            start_of_supervision,
            assessments,
            supervision_contacts,
        )
    if state_code == StateCode.US_ND.value:
        return UsNdSupervisionCaseCompliance(
            supervision_period,
            case_type,
            start_of_supervision,
            assessments,
            supervision_contacts,
        )

    return None
Esempio n. 6
0
    def test_face_to_face_contacts_in_compliance_month(self):
        # TODO(#5199): Update once face to face logic has been implemented.
        evaluation_date = date(2018, 4, 30)

        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=date(2018, 3, 5),  # This was a Monday
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        contacts = []
        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=evaluation_date,
            assessments=[],
            supervision_contacts=contacts,
        )
        self.assertEqual(
            0,
            us_nd_supervision_compliance.
            _face_to_face_contacts_in_compliance_month(evaluation_date),
        )
    def test_home_visit_frequency_sufficient_initial_visit_not_at_residence(
        self, ) -> None:
        """Tests for when the only contact does not have location RESIDENCE."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=StateSupervisionLevel.MINIMUM,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code="US_ND",
                contact_date=start_of_supervision + relativedelta(days=1),
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                status=StateSupervisionContactStatus.COMPLETED,
                location=StateSupervisionContactLocation.SUPERVISION_OFFICE,
            )
        ]

        evaluation_date = start_of_supervision + relativedelta(
            days=NEW_SUPERVISION_HOME_VISIT_DEADLINE_DAYS + 1)

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        home_visit_frequency_sufficient = (
            us_nd_supervision_compliance._home_visit_frequency_is_sufficient(
                evaluation_date))

        self.assertFalse(home_visit_frequency_sufficient)
    def test_reassessment_requirements_are_not_met(self) -> None:
        start_of_supervision = date(2018, 3, 5)  # This was a Monday
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        assessment_date = date(2010, 4, 2)
        assessment_score = 25
        assessment = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_date=assessment_date,
            assessment_score=assessment_score,
        )

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[assessment],
            supervision_contacts=[],
        )

        reassessment_deadline = (
            us_nd_supervision_compliance._next_recommended_reassessment(
                assessment_date,
                assessment_score,
            ))

        self.assertEqual(reassessment_deadline, date(2010, 10, 31))
Esempio n. 9
0
    def test_reassessment_requirements_are_not_met(self):
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=date(2018, 3, 5),  # This was a Monday
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        assessment = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_date=date(2010, 4, 2),
        )

        start_of_supervision = supervision_period.start_date
        evaluation_date = start_of_supervision

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=evaluation_date,
            assessments=[assessment],
            supervision_contacts=[],
        )

        days_past_reassessment = (
            us_nd_supervision_compliance._num_days_past_required_reassessment(
                evaluation_date,
                assessment.assessment_date,
                assessment.assessment_score,
            ))

        self.assertEqual(days_past_reassessment, 2682)
    def test_home_visit_frequency_sufficient_no_initial_visit_within_range(
        self, ) -> None:
        """Tests for when the home visit standard is met because the initial period has
        not yet passed."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=StateSupervisionLevel.MINIMUM,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        supervision_contacts: List[StateSupervisionContact] = []

        evaluation_date = start_of_supervision + relativedelta(days=59)

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        home_visit_frequency_sufficient = (
            us_nd_supervision_compliance._home_visit_frequency_is_sufficient(
                evaluation_date))

        self.assertTrue(home_visit_frequency_sufficient)
    def test_face_to_face_frequency_sufficient_contacts_attempted_general_case(
        self, ) -> None:
        """Tests when the only face to face contact is attempted, but not completed."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
            supervision_level=StateSupervisionLevel.MAXIMUM,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code="US_ND",
                contact_date=supervision_period.start_date,
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                # Only contact was not completed
                status=StateSupervisionContactStatus.ATTEMPTED,
            )
        ]

        evaluation_date = start_of_supervision + relativedelta(days=2)

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        face_to_face_frequency_sufficient = (
            us_nd_supervision_compliance.
            _face_to_face_contact_frequency_is_sufficient(evaluation_date))

        self.assertFalse(face_to_face_frequency_sufficient)
    def test_face_to_face_frequency_sufficient_contacts_before_supervision_start(
        self, ) -> None:
        """Tests for when the only face to face contacts is occurs prior to start of supervision."""
        start_of_supervision = date(2018, 3, 5)
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
            supervision_level=StateSupervisionLevel.MINIMUM,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code="US_ND",
                # Only contact happened before supervision started
                contact_date=start_of_supervision - relativedelta(days=100),
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                status=StateSupervisionContactStatus.COMPLETED,
            )
        ]

        evaluation_date = start_of_supervision + relativedelta(days=3)

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        face_to_face_frequency_sufficient = (
            us_nd_supervision_compliance.
            _face_to_face_contact_frequency_is_sufficient(evaluation_date))

        self.assertFalse(face_to_face_frequency_sufficient)
    def generate_supervision_case_compliance(
        self,
        start_of_supervision: date,
        termination_date: date,
        supervision_level: StateSupervisionLevel,
        contact_dates: List[date],
    ) -> UsNdSupervisionCaseCompliance:
        """Tests face to face contacts for the maximum level case."""
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code="US_ND",
            start_date=start_of_supervision,
            termination_date=termination_date,
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            supervision_level=supervision_level,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code="US_ND",
                contact_date=contact_date,
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                status=StateSupervisionContactStatus.COMPLETED,
            ) for contact_date in contact_dates
        ]

        # note that this is outside 30 days but within the next calendar month
        # so we should be good
        return UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )
    def test_face_to_face_frequency_sufficient(self) -> None:
        """Tests for when the face to face contacts is sufficient."""
        start_of_supervision = date(2018, 3, 5)  # This was a Monday
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=start_of_supervision,
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
            supervision_level=StateSupervisionLevel.MINIMUM,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code=StateCode.US_ND.value,
                contact_date=supervision_period.start_date,
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                status=StateSupervisionContactStatus.COMPLETED,
            )
        ]

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=start_of_supervision,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        self.assertTrue(
            us_nd_supervision_compliance.
            _face_to_face_contact_frequency_is_sufficient(
                start_of_supervision))
Esempio n. 15
0
    def test_face_to_face_frequency_sufficient(self):
        # TODO(#5199): Update once face to face logic is implemented.
        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=date(2018, 3, 5),  # This was a Monday
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        supervision_contacts = [
            StateSupervisionContact.new_with_defaults(
                state_code=StateCode.US_ND.value,
                contact_date=supervision_period.start_date,
                contact_type=StateSupervisionContactType.FACE_TO_FACE,
                status=StateSupervisionContactStatus.COMPLETED,
            )
        ]

        start_of_supervision = supervision_period.start_date
        evaluation_date = start_of_supervision

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=evaluation_date,
            assessments=[],
            supervision_contacts=supervision_contacts,
        )

        self.assertIsNone(
            us_nd_supervision_compliance.
            _face_to_face_contact_frequency_is_sufficient(evaluation_date))
    def test_completed_assessments_in_compliance_month(self) -> None:
        evaluation_date = date(2018, 4, 30)
        assessment_out_of_range = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_date=date(2018, 3, 10),
        )
        assessment_out_of_range_2 = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_date=date(2018, 5, 10),
        )
        assessment_1 = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_score=1,
            assessment_date=date(2018, 4, 30),
        )
        assessment_2 = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_score=100,
            assessment_date=date(2018, 4, 30),
        )
        assessment_no_score = StateAssessment.new_with_defaults(
            state_code=StateCode.US_ND.value,
            assessment_type=StateAssessmentType.LSIR,
            assessment_date=date(2018, 4, 28),
        )

        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=date(2018, 3, 5),  # This was a Monday
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        assessments = [
            assessment_out_of_range,
            assessment_out_of_range_2,
            assessment_1,
            assessment_2,
            assessment_no_score,
        ]
        expected_assessments = [assessment_1, assessment_2]

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=evaluation_date,
            assessments=assessments,
            supervision_contacts=[],
        )

        self.assertEqual(
            len(expected_assessments),
            us_nd_supervision_compliance._completed_assessments_on_date(
                evaluation_date),
        )
    def test_face_to_face_contacts_in_compliance_month(self) -> None:
        evaluation_date = date(2018, 4, 30)
        contact_1 = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 4, 1),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
        )
        contact_2 = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 4, 15),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
        )
        contact_3 = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 4, 30),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
        )
        contact_out_of_range = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 3, 30),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.COMPLETED,
        )
        contact_incomplete = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 4, 30),
            contact_type=StateSupervisionContactType.FACE_TO_FACE,
            status=StateSupervisionContactStatus.ATTEMPTED,
        )
        contact_wrong_type = StateSupervisionContact.new_with_defaults(
            state_code="US_ND",
            contact_date=date(2018, 4, 30),
            contact_type=StateSupervisionContactType.WRITTEN_MESSAGE,
            status=StateSupervisionContactStatus.COMPLETED,
        )

        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            external_id="sp1",
            state_code=StateCode.US_ND.value,
            start_date=date(2018, 3, 5),  # This was a Monday
            termination_date=date(2018, 5, 19),
            admission_reason=StateSupervisionPeriodAdmissionReason.
            COURT_SENTENCE,
            termination_reason=StateSupervisionPeriodTerminationReason.
            DISCHARGE,
            supervision_period_supervision_type=
            StateSupervisionPeriodSupervisionType.PROBATION,
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )

        contacts = [
            contact_1,
            contact_2,
            contact_3,
            contact_incomplete,
            contact_out_of_range,
            contact_wrong_type,
        ]
        expected_contacts = [contact_3]

        us_nd_supervision_compliance = UsNdSupervisionCaseCompliance(
            self.person,
            supervision_period=supervision_period,
            case_type=StateSupervisionCaseType.GENERAL,
            start_of_supervision=evaluation_date,
            assessments=[],
            supervision_contacts=contacts,
        )
        self.assertEqual(
            len(expected_contacts),
            us_nd_supervision_compliance._face_to_face_contacts_on_date(
                evaluation_date),
        )