Skip to content

Commit

Permalink
Fixing #673
Browse files Browse the repository at this point in the history
  • Loading branch information
bltravis committed Nov 1, 2023
1 parent d9f76a0 commit 6b43f62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def remove_from_id_map(self, former_ids: List[str]):
if former_id in self.id_map:
del self.id_map[former_id]

def create_entity(self, entity_mappings, marc_field, entity_parent_key, index_or_legacy_id):
def create_entity(self, entity_mappings, marc_field: Field, entity_parent_key, index_or_legacy_id):
entity = {}
parent_schema_prop = self.schema.get("properties", {}).get(entity_parent_key, {})
if parent_schema_prop.get("type", "") == "array":
Expand All @@ -548,6 +548,9 @@ def create_entity(self, entity_mappings, marc_field, entity_parent_key, index_or
req_entity_props = []
for entity_mapping in entity_mappings:
k = entity_mapping["target"].split(".")[-1]
if k == "authorityId" and (legacy_subfield_9 := marc_field.get("9")):
marc_field.add_subfield("0", legacy_subfield_9)
marc_field.delete_subfield("9")
if my_values := [
v
for v in self.apply_rules(marc_field, entity_mapping, index_or_legacy_id)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_rules_mapper_bibs_no_folio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from datetime import datetime
from unittest.mock import Mock

import i18n
import pymarc
import pytest
import i18n
from dateutil.parser import parse
from pymarc import Field
from pymarc import MARCReader
Expand Down Expand Up @@ -163,6 +163,7 @@ def test_create_entity_empty_props(mapper: BibsRulesMapper):
Subfield(code="a", value="De Geer, Jan,"),
Subfield(code="d", value="1918-2007"),
Subfield(code="0", value="280552"),
Subfield(code="9", value="someid")
],
)
entity = mapper.create_entity(entity_mappings, marc_field, "contributors", "apa")
Expand Down

0 comments on commit 6b43f62

Please sign in to comment.