def testParseStateIncarcerationIncident(self):
        # Arrange
        ingest_incident_outcome = \
            ingest_info_pb2.StateIncarcerationIncidentOutcome(
                state_incarceration_incident_outcome_id='INCIDENT_OUTCOME_ID',
                outcome_type='LCP',
                date_effective='1/2/2019',
                state_code='us_ca',
                outcome_description='Loss of Commissary Privileges',
                punishment_length_days='45',
            )

        # Act
        result = state_incarceration_incident_outcome.convert(
            ingest_incident_outcome, _METADATA_WITH_OVERRIDES)

        # Assert
        expected_result = entities.StateIncarcerationIncidentOutcome(
            external_id='INCIDENT_OUTCOME_ID',
            outcome_type=StateIncarcerationIncidentOutcomeType.PRIVILEGE_LOSS,
            outcome_type_raw_text='LCP',
            date_effective=date(year=2019, month=1, day=2),
            state_code='US_CA',
            outcome_description='LOSS OF COMMISSARY PRIVILEGES',
            punishment_length_days=45,
        )

        print(result)
        print(expected_result)
        self.assertEqual(result, expected_result)
    def testParseStateIncarcerationIncident(self):
        # Arrange
        ingest_incident_outcome = ingest_info_pb2.StateIncarcerationIncidentOutcome(
            state_incarceration_incident_outcome_id="INCIDENT_OUTCOME_ID",
            outcome_type="LCP",
            date_effective="1/2/2019",
            hearing_date="12/29/2018",
            report_date="12/30/2019",
            state_code="us_ca",
            outcome_description="Loss of Commissary Privileges",
            punishment_length_days="45",
        )

        # Act
        result = state_incarceration_incident_outcome.convert(
            ingest_incident_outcome, _METADATA_WITH_OVERRIDES)

        # Assert
        expected_result = entities.StateIncarcerationIncidentOutcome(
            external_id="INCIDENT_OUTCOME_ID",
            outcome_type=StateIncarcerationIncidentOutcomeType.PRIVILEGE_LOSS,
            outcome_type_raw_text="LCP",
            date_effective=date(year=2019, month=1, day=2),
            hearing_date=date(year=2018, month=12, day=29),
            report_date=date(year=2019, month=12, day=30),
            state_code="US_CA",
            outcome_description="LOSS OF COMMISSARY PRIVILEGES",
            punishment_length_days=45,
        )

        print(result)
        print(expected_result)
        self.assertEqual(result, expected_result)
Beispiel #3
0
    def _convert_incarceration_incident(
        self, ingest_incident: StateIncarcerationIncident
    ) -> entities.StateIncarcerationIncident:
        """Converts an ingest_info proto StateIncarcerationIncident to a
        persistence entity."""
        incident_builder = entities.StateIncarcerationIncident.builder()

        state_incarceration_incident.copy_fields_to_builder(
            incident_builder, ingest_incident, self.metadata)

        incident_builder.responding_officer = fn(
            lambda i: state_agent.convert(self.agents[i], self.metadata),
            "responding_officer_id",
            ingest_incident,
        )

        converted_outcomes = [
            state_incarceration_incident_outcome.convert(
                self.incarceration_incident_outcomes[outcome_id],
                self.metadata) for outcome_id in
            ingest_incident.state_incarceration_incident_outcome_ids
        ]

        incident_builder.incarceration_incident_outcomes = converted_outcomes
        return incident_builder.build()