Skip to content

Commit

Permalink
Why these changes are being introduced:
Browse files Browse the repository at this point in the history
It was discovered that some ASpace records after transformation contained multiple identifiers, of the same type,
which was throwing errors in Bento.  It looks as though ASpace records may have changed slightly and are
exposing a new string for the <unitid> element, which is the same as the OAI record identifier.

How this addresses that need:

When iterating through <unitid> elements, by skipping those with attribute type=aspace_uri, we can
skip adding that particular <unitid> as a TIMDEX record identifier.

Side effects of this change:

Believed to be none.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/TIMX-234
  • Loading branch information
ghukill committed Aug 16, 2023
1 parent 4fcb617 commit 8a93575
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 39 deletions.
74 changes: 35 additions & 39 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
<unitid>
<emph>Data enclosed in subelement</emph>
</unitid>
<unitid type="aspace_uri">
<emph>unitid-that-should-not-be-identifier</emph>
</unitid>
<abstract>
<emph>Data enclosed in subelement</emph>
</abstract>
Expand Down
9 changes: 9 additions & 0 deletions tests/test_ead.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,15 @@ def test_ead_record_invalid_date_and_date_range_are_omitted(caplog):
) in caplog.text


def test_ead_record_correct_identifiers_from_multiple_unitid(caplog):
ead_xml_records = parse_xml_records(
"tests/fixtures/ead/ead_record_attribute_and_subfield_variations.xml"
)
output_record = next(Ead("aspace", ead_xml_records))
for identifier in output_record.identifiers:
assert identifier.value != "unitid-that-should-not-be-identifier"


def test_ead_record_with_missing_optional_fields_transforms_correctly():
ead_xml_records = parse_xml_records(
"tests/fixtures/ead/ead_record_missing_optional_fields.xml"
Expand Down
2 changes: 2 additions & 0 deletions transmogrifier/sources/ead.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def get_optional_fields(self, xml: Tag) -> Optional[dict]:
for id_element in collection_description_did.find_all(
"unitid", recursive=False
):
if id_element.get("type") == "aspace_uri":
continue
if id_value := self.create_string_from_mixed_value(
id_element,
" ",
Expand Down

0 comments on commit 8a93575

Please sign in to comment.