コード例 #1
0
    def test_filter_violation_responses_do_include_supplemental(self):
        supervision_violation_responses = [
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.CITATION,
            ),
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='SUP'  # Should be included
            )
        ]

        filtered_responses = us_mo_filter_violation_responses(
            supervision_violation_responses, include_follow_up_responses=True)
        expected_output = [
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.CITATION,
            ),
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='SUP'  # Should be included
            )
        ]

        self.assertEqual(expected_output, filtered_responses)
コード例 #2
0
def filter_violation_responses_before_revocation(violation_responses: List[StateSupervisionViolationResponse]) -> \
        List[StateSupervisionViolationResponse]:
    """State-specific filtering of the violation responses that should be included in pre-revocation analysis."""
    if violation_responses:
        state_code = violation_responses[0].state_code
        if state_code == 'US_MO':
            return us_mo_filter_violation_responses(violation_responses)
    return violation_responses
コード例 #3
0
def state_specific_filter_of_violation_responses(
    violation_responses: List[StateSupervisionViolationResponse],
    include_follow_up_responses: bool,
) -> List[StateSupervisionViolationResponse]:
    """State-specific filtering of the violation responses that should be included analysis."""
    if violation_responses:
        state_code = violation_responses[0].state_code
        if state_code.upper() == "US_MO":
            return us_mo_filter_violation_responses(
                violation_responses, include_follow_up_responses
            )
    return violation_responses
コード例 #4
0
    def test_filter_violation_responses_unexpected_subtype(self):
        supervision_violation_responses = [
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='XXX'  # Not one we expect to see
            )
        ]

        with pytest.raises(ValueError):
            _ = us_mo_filter_violation_responses(
                supervision_violation_responses,
                include_follow_up_responses=True)
コード例 #5
0
    def test_filter_violation_responses_ITR(self) -> None:
        supervision_violation_responses = [
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.CITATION,
            ),
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='ITR'  # Should be included
            )
        ]

        filtered_responses = us_mo_filter_violation_responses(
            supervision_violation_responses, include_follow_up_responses=True)

        self.assertEqual(supervision_violation_responses, filtered_responses)
コード例 #6
0
    def test_filter_violation_responses_none_valid(self):
        supervision_violation_responses = [
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='SUP'  # Should not be included
            ),
            StateSupervisionViolationResponse.new_with_defaults(
                state_code='US_MO',
                response_type=StateSupervisionViolationResponseType.
                VIOLATION_REPORT,
                response_subtype='HOF'  # Should not be included
            )
        ]

        filtered_responses = us_mo_filter_violation_responses(
            supervision_violation_responses, include_follow_up_responses=False)
        expected_output = []

        self.assertEqual(expected_output, filtered_responses)