def _parse_state_external_id(id_str):
    """Undoes preprocessing of state_person_external_ids done when converting
    from ingest_info py -> ingest_info proto.
    """
    synthetic_id = parse_external_id(id_str)
    external_id = get_external_id(synthetic_id=synthetic_id)
    return normalize(external_id)
Exemple #2
0
 def _process_external_ids(ii: ingest_info.IngestInfo) -> None:
     # Undo preprocessing on external_ids performed when converting from
     # py -> proto
     for p in ii.state_people:
         for ex_id in p.state_person_external_ids:
             existing_id = cast(str, ex_id.state_person_external_id_id)
             ex_id.state_person_external_id_id = get_external_id(
                 synthetic_id=existing_id)
def convert(proto: StatePersonExternalId,
            metadata: IngestMetadata) -> entities.StatePersonExternalId:
    """Converts an ingest_info proto Hold to a persistence entity."""
    new = entities.StatePersonExternalId.builder()

    # The ingest info -> proto converter appends the id_type to the external id to keep external ids globally unique.
    new.external_id = get_external_id(
        synthetic_id=getattr(proto, "state_person_external_id_id"))
    new.id_type = getattr(proto, "id_type")
    new.state_code = metadata.region

    return new.build(StatePersonExternalIdFactory.deserialize)
 def test_get_external_id(self) -> None:
     synthetic_id = "id_type:11:111"
     self.assertEqual("11:111", get_external_id(synthetic_id=synthetic_id))