def generate_supervision_violation_response_decision_entry(
        person,
        **kwargs) -> schema.StateSupervisionViolationResponseDecisionEntry:
    args = {
        "state_code": _STATE_CODE,
    }
    args.update(kwargs)
    return schema.StateSupervisionViolationResponseDecisionEntry(person=person,
                                                                 **args)
Exemple #2
0
def generate_test_supervision_violation_response(person_id) -> \
        state_schema.StateSupervisionViolationResponse:
    instance = state_schema.StateSupervisionViolationResponse(
        supervision_violation_response_id=456,
        state_code='us_ca',
        person_id=person_id,
        supervision_violation_response_decisions=[
            state_schema.StateSupervisionViolationResponseDecisionEntry(
                supervision_violation_response_decision_entry_id=123,
                state_code='us_ca',
                decision=StateSupervisionViolationResponseDecision.REVOCATION.
                value,
                decision_raw_text='REV',
                revocation_type=StateSupervisionViolationResponseRevocationType
                .REINCARCERATION.value,
                revocation_type_raw_text='REINC',
                person_id=person_id,
            )
        ])

    return instance
    def build_data_dict(
            fake_person_id: int,
            fake_supervision_violation_id: int) -> Dict[str, List[Any]]:
        """Builds a data_dict for a basic run of the pipeline."""
        fake_person = schema.StatePerson(
            state_code="US_XX",
            person_id=fake_person_id,
            gender=Gender.FEMALE,
            birthdate=date(1985, 2, 1),
        )
        persons_data = [normalized_database_base_dict(fake_person)]

        race_1 = schema.StatePersonRace(
            person_race_id=111,
            state_code="US_XX",
            race=Race.ASIAN,
            person_id=fake_person_id,
        )
        race_2 = schema.StatePersonRace(
            person_race_id=111,
            state_code="US_XX",
            race=Race.AMERICAN_INDIAN_ALASKAN_NATIVE,
            person_id=fake_person_id,
        )

        races_data = normalized_database_base_dict_list([race_1, race_2])

        ethnicity = schema.StatePersonEthnicity(
            person_ethnicity_id=111,
            state_code="US_XX",
            ethnicity=Ethnicity.NOT_HISPANIC,
            person_id=fake_person_id,
        )

        ethnicity_data = normalized_database_base_dict_list([ethnicity])

        violation_type = schema.StateSupervisionViolationTypeEntry(
            state_code="US_XX",
            violation_type=StateSupervisionViolationType.FELONY,
            person_id=fake_person_id,
        )
        incomplete_response = schema.StateSupervisionViolationResponse(
            state_code="US_XX",
            supervision_violation_response_id=1234,
            response_type=entities.StateSupervisionViolationResponseType.
            VIOLATION_REPORT,
            response_date=date(2021, 1, 4),
            is_draft=False,
            person_id=fake_person_id,
        )
        violation = schema.StateSupervisionViolation(
            state_code="US_XX",
            supervision_violation_id=fake_supervision_violation_id,
            violation_date=date(2021, 1, 1),
            is_violent=False,
            is_sex_offense=False,
            supervision_violation_types=[violation_type],
            supervision_violation_responses=[incomplete_response],
            person_id=fake_person_id,
        )
        incomplete_response.supervision_violation_id = fake_supervision_violation_id
        violation_type.supervision_violation_id = fake_supervision_violation_id

        violation_decision = schema.StateSupervisionViolationResponseDecisionEntry(
            state_code="US_XX",
            decision=StateSupervisionViolationResponseDecision.
            SHOCK_INCARCERATION,
            person_id=fake_person_id,
            supervision_violation_response_decision_entry_id=234,
            supervision_violation_response_id=1234,
        )
        complete_violation_response = schema.StateSupervisionViolationResponse(
            state_code="US_XX",
            supervision_violation_response_id=1234,
            response_type=entities.StateSupervisionViolationResponseType.
            VIOLATION_REPORT,
            response_date=date(2021, 1, 4),
            is_draft=False,
            supervision_violation_response_decisions=[violation_decision],
            person_id=fake_person_id,
        )
        complete_violation_response.supervision_violation_id = (
            fake_supervision_violation_id)

        violations_data = [normalized_database_base_dict(violation)]
        violation_responses_data = [
            normalized_database_base_dict(complete_violation_response)
        ]
        violation_types_data = [normalized_database_base_dict(violation_type)]
        violation_decisions_data = [
            normalized_database_base_dict(violation_decision)
        ]

        state_race_ethnicity_population_count_data = [{
            "state_code":
            "US_XX",
            "race_or_ethnicity":
            "ASIAN",
            "population_count":
            1,
            "representation_priority":
            1,
        }]

        data_dict: Dict[str, List[Any]] = {
            schema.StatePerson.__tablename__:
            persons_data,
            schema.StatePersonRace.__tablename__:
            races_data,
            schema.StatePersonEthnicity.__tablename__:
            ethnicity_data,
            schema.StateSupervisionViolation.__tablename__:
            violations_data,
            schema.StateSupervisionViolationResponse.__tablename__:
            violation_responses_data,
            schema.StateSupervisionViolationTypeEntry.__tablename__:
            violation_types_data,
            schema.StateSupervisionViolatedConditionEntry.__tablename__: [],
            schema.StateSupervisionViolationResponseDecisionEntry.__tablename__:
            violation_decisions_data,
            schema.StatePersonExternalId.__tablename__: [],
            schema.StatePersonAlias.__tablename__: [],
            schema.StateAssessment.__tablename__: [],
            schema.StateProgramAssignment.__tablename__: [],
            schema.StateSentenceGroup.__tablename__: [],
            "state_race_ethnicity_population_counts":
            state_race_ethnicity_population_count_data,
        }
        return data_dict