def testParseStateSentenceGroup(self): # Arrange ingest_group = ingest_info_pb2.StateSentenceGroup( status="SUSPENDED", state_sentence_group_id="GROUP_ID", date_imposed="1/2/2111", county_code="CO", min_length="200", max_length="600", is_life="false", ) # Act group_builder = entities.StateSentenceGroup.builder() state_sentence_group.copy_fields_to_builder(group_builder, ingest_group, METADATA) result = group_builder.build(StateSentenceGroupFactory.deserialize) # Assert expected_result = entities.StateSentenceGroup( status=StateSentenceStatus.SUSPENDED, status_raw_text="SUSPENDED", external_id="GROUP_ID", date_imposed=date(year=2111, month=1, day=2), state_code="US_ND", county_code="CO", min_length_days=200, max_length_days=600, is_life=False, ) self.assertEqual(result, expected_result)
def _convert_sentence_group(self, ingest_sentence_group: StateSentenceGroup) \ -> entities.StateSentenceGroup: """Converts an ingest_info proto StateSentenceGroup to a persistence entity.""" sentence_group_builder = entities.StateSentenceGroup.builder() state_sentence_group.copy_fields_to_builder(sentence_group_builder, ingest_sentence_group, self.metadata) converted_supervision_sentences = [ self._convert_supervision_sentence( self.supervision_sentences[sentence_id]) for sentence_id in ingest_sentence_group.state_supervision_sentence_ids ] sentence_group_builder.supervision_sentences = \ converted_supervision_sentences converted_incarceration_sentences = [ self._convert_incarceration_sentence( self.incarceration_sentences[sentence_id]) for sentence_id in ingest_sentence_group.state_incarceration_sentence_ids ] sentence_group_builder.incarceration_sentences = \ converted_incarceration_sentences converted_fines = [ self._convert_fine(self.fines[fine_id]) for fine_id in ingest_sentence_group.state_fine_ids ] sentence_group_builder.fines = converted_fines return sentence_group_builder.build()
def testParseStateSentenceGroup(self): # Arrange ingest_group = ingest_info_pb2.StateSentenceGroup( status='SUSPENDED', state_sentence_group_id='GROUP_ID', date_imposed='1/2/2111', county_code='CO', min_length='200D', max_length='600D', is_life='false', ) # Act group_builder = entities.StateSentenceGroup.builder() state_sentence_group.copy_fields_to_builder(group_builder, ingest_group, METADATA) result = group_builder.build() # Assert expected_result = entities.StateSentenceGroup( status=StateSentenceStatus.SUSPENDED, status_raw_text='SUSPENDED', external_id='GROUP_ID', date_imposed=date(year=2111, month=1, day=2), state_code='US_ND', county_code='CO', min_length_days=200, max_length_days=600, is_life=False, ) self.assertEqual(result, expected_result)