Exemple #1
0
    def test_find_program_participation_events_not_actively_participating(
            self):
        program_assignment = StateProgramAssignment.new_with_defaults(
            state_code="US_XX",
            program_id="PG3",
            referral_date=date(2009, 10, 3),
            participation_status=StateProgramAssignmentParticipationStatus.
            DISCHARGED,
            program_location_id="LOCATION",
            start_date=date(2009, 11, 5),
            discharge_date=date(2009, 11, 8),
        )

        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            status=StateSupervisionPeriodStatus.UNDER_SUPERVISION,
            state_code="US_XX",
            start_date=date(1990, 3, 5),
            supervision_type=StateSupervisionType.PAROLE,
        )

        supervision_periods = [supervision_period]

        participation_events = identifier.find_program_participation_events(
            program_assignment, supervision_periods)

        expected_events = [
            ProgramParticipationEvent(
                state_code=program_assignment.state_code,
                program_id=program_assignment.program_id,
                event_date=program_assignment.start_date,
                is_first_day_in_program=True,
                program_location_id=program_assignment.program_location_id,
                supervision_type=supervision_period.supervision_type,
            ),
            ProgramParticipationEvent(
                state_code=program_assignment.state_code,
                program_id=program_assignment.program_id,
                event_date=program_assignment.start_date +
                relativedelta(days=1),
                is_first_day_in_program=False,
                program_location_id=program_assignment.program_location_id,
                supervision_type=supervision_period.supervision_type,
            ),
            ProgramParticipationEvent(
                state_code=program_assignment.state_code,
                program_id=program_assignment.program_id,
                event_date=program_assignment.start_date +
                relativedelta(days=2),
                is_first_day_in_program=False,
                program_location_id=program_assignment.program_location_id,
                supervision_type=supervision_period.supervision_type,
            ),
        ]

        self.assertListEqual(expected_events, participation_events)
Exemple #2
0
    def test_find_program_participation_events_no_start_date(self):
        program_assignment = StateProgramAssignment.new_with_defaults(
            state_code='US_CA',
            program_id='PG3',
            referral_date=date(1999, 10, 3),
            # This program assignment is in progress, but it's missing a required start_date
            participation_status=StateProgramAssignmentParticipationStatus.
            IN_PROGRESS,
            program_location_id='LOCATION')

        supervision_periods = []

        participation_events = identifier.find_program_participation_events(
            program_assignment, supervision_periods)

        self.assertEqual([], participation_events)
Exemple #3
0
    def test_find_program_participation_events_no_discharge_date(self):
        program_assignment = StateProgramAssignment.new_with_defaults(
            state_code='US_CA',
            program_id='PG3',
            referral_date=date(1999, 10, 3),
            # This program assignment has a DISCHARGED status, but it's missing a required discharge_date
            participation_status=StateProgramAssignmentParticipationStatus.
            DISCHARGED,
            program_location_id='LOCATION',
            start_date=date(1999, 11, 2))

        supervision_periods = []

        participation_events = identifier.find_program_participation_events(
            program_assignment, supervision_periods)

        self.assertEqual([], participation_events)
Exemple #4
0
    def test_find_program_participation_events(self):
        program_assignment = StateProgramAssignment.new_with_defaults(
            state_code='US_XX',
            program_id='PG3',
            referral_date=date(1999, 10, 3),
            participation_status=StateProgramAssignmentParticipationStatus.IN_PROGRESS,
            program_location_id='LOCATION',
            start_date=date(1999, 12, 31)
        )

        supervision_period = StateSupervisionPeriod.new_with_defaults(
            supervision_period_id=111,
            status=StateSupervisionPeriodStatus.UNDER_SUPERVISION,
            state_code='US_XX',
            start_date=date(1990, 3, 5),
            supervision_type=StateSupervisionType.PAROLE
        )

        supervision_periods = [supervision_period]

        participation_events = identifier.find_program_participation_events(
            program_assignment, supervision_periods
        )

        expected_events = [ProgramParticipationEvent(
            state_code=program_assignment.state_code,
            program_id=program_assignment.program_id,
            event_date=program_assignment.start_date,
            is_first_day_in_program=True,
            program_location_id=program_assignment.program_location_id,
            supervision_type=supervision_period.supervision_type
        ), ProgramParticipationEvent(
            state_code=program_assignment.state_code,
            program_id=program_assignment.program_id,
            event_date=program_assignment.start_date + relativedelta(days=1),
            is_first_day_in_program=False,
            program_location_id=program_assignment.program_location_id,
            supervision_type=supervision_period.supervision_type
        )]

        self.assertListEqual(expected_events, participation_events)