def testParseStateSupervisionSentence(self): # Arrange ingest_supervision = ingest_info_pb2.StateSupervisionSentence( status='SUSPENDED', supervision_type='PROBATION', state_supervision_sentence_id='SENTENCE_ID', completion_date='1/2/2111', county_code='CO', min_length='90D', max_length='180D' ) # Act supervision_builder = entities.StateSupervisionSentence.builder() state_supervision_sentence.copy_fields_to_builder( supervision_builder, ingest_supervision, METADATA) result = supervision_builder.build() # Assert expected_result = entities.StateSupervisionSentence( status=StateSentenceStatus.SUSPENDED, status_raw_text='SUSPENDED', supervision_type=StateSupervisionType.PROBATION, supervision_type_raw_text='PROBATION', external_id='SENTENCE_ID', completion_date=None, projected_completion_date=date(year=2111, month=1, day=2), state_code='US_ND', county_code='CO', min_length_days=90, max_length_days=180 ) self.assertEqual(result, expected_result)
def _convert_supervision_sentence( self, ingest_supervision_sentence: StateSupervisionSentence) \ -> entities.StateSupervisionSentence: """Converts an ingest_info proto StateSupervisionSentence to a persistence entity.""" supervision_sentence_builder = \ entities.StateSupervisionSentence.builder() state_supervision_sentence.copy_fields_to_builder( supervision_sentence_builder, ingest_supervision_sentence, self.metadata) self._copy_children_to_sentence(supervision_sentence_builder, ingest_supervision_sentence) return supervision_sentence_builder.build()
def testParseStateSupervisionSentence(self): # Arrange ingest_supervision = ingest_info_pb2.StateSupervisionSentence( status="SUSPENDED", supervision_type="PROBATION", state_supervision_sentence_id="SENTENCE_ID", date_imposed="2000-12-13", start_date="20010101", completion_date="1/2/2111", county_code="CO", min_length="90D", max_length="180D", ) # Act supervision_builder = entities.StateSupervisionSentence.builder() state_supervision_sentence.copy_fields_to_builder( supervision_builder, ingest_supervision, METADATA) result = supervision_builder.build() # Assert expected_result = entities.StateSupervisionSentence( status=StateSentenceStatus.SUSPENDED, status_raw_text="SUSPENDED", supervision_type=StateSupervisionType.PROBATION, supervision_type_raw_text="PROBATION", external_id="SENTENCE_ID", date_imposed=date(year=2000, month=12, day=13), start_date=date(year=2001, month=1, day=1), completion_date=None, projected_completion_date=date(year=2111, month=1, day=2), state_code="US_ND", county_code="CO", min_length_days=90, max_length_days=180, ) self.assertEqual(result, expected_result)