def test_include_event_in_count_supervision_type_unset(self):
        """Tests the include_event_in_count function when there are two events in the same month, but of different
        supervision types, and the combo does not specify the supervision type."""

        combo = {
            'metric_type': 'PROGRAM_REFERRAL'
        }

        program_event_1 = ProgramReferralEvent(
            state_code='US_ND',
            event_date=date(2020, 1, 3),
            program_id='XXX',
            supervision_type=StateSupervisionType.PROBATION
        )

        program_event_2 = ProgramReferralEvent(
            state_code='US_ND',
            event_date=date(2020, 1, 9),
            program_id='XXX',
            supervision_type=StateSupervisionType.PAROLE
        )

        events_in_period = [program_event_1, program_event_2]

        end_date = date(2020, 1, 31)

        include_first = calculator.include_event_in_count(
            combo, program_event_1, end_date, events_in_period)

        self.assertFalse(include_first)

        include_second = calculator.include_event_in_count(
            combo, program_event_2, end_date, events_in_period)

        self.assertTrue(include_second)
Exemple #2
0
    def test_include_participation_event_in_count_multiple_same_day_do_not_include(
            self):
        """Tests the include_event_in_count function when the participation event should not be included because its
        program_location_id is not alphabetically before the other program_location_ids."""

        combo = {'metric_type': 'PARTICIPATION'}

        program_event_1 = ProgramParticipationEvent(state_code='US_ND',
                                                    event_date=date(
                                                        2020, 1, 3),
                                                    program_id='XXX',
                                                    program_location_id='Z')

        program_event_2 = ProgramParticipationEvent(state_code='US_ND',
                                                    event_date=date(
                                                        2020, 1, 3),
                                                    program_id='XXX',
                                                    program_location_id='B')

        program_event_3 = ProgramParticipationEvent(state_code='US_ND',
                                                    event_date=date(
                                                        2020, 1, 3),
                                                    program_id='XXX',
                                                    program_location_id='C')

        end_date = date(2020, 1, 31)

        program_events = [program_event_1, program_event_2, program_event_3]

        include = calculator.include_event_in_count(combo, program_event_1,
                                                    end_date, program_events)

        self.assertFalse(include)
    def test_include_event_in_count_last_of_many_unsorted(self):
        """Tests the include_event_in_count function when the event should be included because it is the last one before
        the end of the time period."""

        combo = {
            'metric_type': 'PROGRAM_REFERRAL'
        }

        program_event_1 = ProgramReferralEvent(
            state_code='US_ND',
            event_date=date(2017, 2, 3),
            program_id='XXX'
        )

        program_event_2 = ProgramReferralEvent(
            state_code='US_ND',
            event_date=date(2020, 1, 30),
            program_id='XXX'
        )

        program_event_3 = ProgramReferralEvent(
            state_code='US_ND',
            event_date=date(2018, 3, 11),
            program_id='XXX'
        )

        events_in_period = [program_event_1, program_event_2, program_event_3]

        end_date = date(2020, 1, 31)

        include = calculator.include_event_in_count(
            combo, program_event_2, end_date, events_in_period)

        self.assertTrue(include)
Exemple #4
0
    def test_include_event_in_count(self):
        """Tests the include_event_in_count function when the referral should be included."""

        combo = {'metric_type': 'PARTICIPATION'}

        program_event = ProgramParticipationEvent(state_code='US_ND',
                                                  event_date=date(2020, 1, 3),
                                                  program_id='XXX')

        end_date = date(2020, 1, 31)

        include = calculator.include_event_in_count(combo, program_event,
                                                    end_date, [program_event])

        self.assertTrue(include)