def _convert_early_discharge( self, ingest_early_discharge: StateEarlyDischarge ) -> entities.StateIncarcerationSentence: """Converts an ingest_info proto StateEarlyDischarge to a persistence entity.""" early_discharge_builder = entities.StateEarlyDischarge.builder() state_early_discharge.copy_fields_to_builder(early_discharge_builder, ingest_early_discharge, self.metadata) return early_discharge_builder.build()
def testParseStateSupervisionViolationResponse(self): # Arrange ingest_response = ingest_info_pb2.StateEarlyDischarge( state_early_discharge_id="id1", request_date="2010/07/01", decision_date="2010/08/01", decision="REQUEST_DENIED", decision_status="DECIDED", deciding_body_type="COURT", requesting_body_type="SUPERVISION_OFFICER", state_code="us_nd", county_code="cty", ) # Act response_builder = entities.StateEarlyDischarge.builder() state_early_discharge.copy_fields_to_builder(response_builder, ingest_response, _EMPTY_METADATA) result = response_builder.build() # Assert expected_result = entities.StateEarlyDischarge.new_with_defaults( external_id="ID1", request_date=date(year=2010, month=7, day=1), decision_date=date(year=2010, month=8, day=1), decision=StateEarlyDischargeDecision.REQUEST_DENIED, decision_raw_text="REQUEST_DENIED", decision_status=StateEarlyDischargeDecisionStatus.DECIDED, decision_status_raw_text="DECIDED", deciding_body_type=StateActingBodyType.COURT, deciding_body_type_raw_text="COURT", requesting_body_type=StateActingBodyType.SUPERVISION_OFFICER, requesting_body_type_raw_text="SUPERVISION_OFFICER", state_code="US_ND", county_code="CTY", ) self.assertEqual(result, expected_result)
def testParseStateSupervisionViolationResponse(self): # Arrange ingest_response = ingest_info_pb2.StateEarlyDischarge( state_early_discharge_id='id1', request_date='2010/07/01', decision_date='2010/08/01', decision='REQUEST_DENIED', deciding_body_type='COURT', requesting_body_type='SUPERVISION_OFFICER', state_code='us_nd', county_code='cty', ) # Act response_builder = entities.StateEarlyDischarge.builder() state_early_discharge.copy_fields_to_builder(response_builder, ingest_response, _EMPTY_METADATA) result = response_builder.build() # Assert expected_result = entities.StateEarlyDischarge.new_with_defaults( external_id='ID1', request_date=date(year=2010, month=7, day=1), decision_date=date(year=2010, month=8, day=1), decision=StateEarlyDischargeDecision.REQUEST_DENIED, decision_raw_text='REQUEST_DENIED', deciding_body_type=StateActingBodyType.COURT, deciding_body_type_raw_text='COURT', requesting_body_type=StateActingBodyType.SUPERVISION_OFFICER, requesting_body_type_raw_text='SUPERVISION_OFFICER', state_code='US_ND', county_code='CTY', ) self.assertEqual(result, expected_result)