Skip to content

Commit 4557960

Browse files
authored
Merge pull request #102 from MITLibraries/TIMX-234-update-aspace-identifiers
Why these changes are being introduced:
2 parents 4fcb617 + 772feb8 commit 4557960

File tree

4 files changed

+49
-39
lines changed

4 files changed

+49
-39
lines changed

Pipfile.lock

+35-39
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fixtures/ead/ead_record_attribute_and_subfield_variations.xml

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<unitid>
6060
<emph>Data enclosed in subelement</emph>
6161
</unitid>
62+
<unitid type="aspace_uri">
63+
<emph>unitid-that-should-not-be-identifier</emph>
64+
</unitid>
6265
<abstract>
6366
<emph>Data enclosed in subelement</emph>
6467
</abstract>

tests/test_ead.py

+9
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,15 @@ def test_ead_record_invalid_date_and_date_range_are_omitted(caplog):
526526
) in caplog.text
527527

528528

529+
def test_ead_record_correct_identifiers_from_multiple_unitid(caplog):
530+
ead_xml_records = parse_xml_records(
531+
"tests/fixtures/ead/ead_record_attribute_and_subfield_variations.xml"
532+
)
533+
output_record = next(Ead("aspace", ead_xml_records))
534+
for identifier in output_record.identifiers:
535+
assert identifier.value != "unitid-that-should-not-be-identifier"
536+
537+
529538
def test_ead_record_with_missing_optional_fields_transforms_correctly():
530539
ead_xml_records = parse_xml_records(
531540
"tests/fixtures/ead/ead_record_missing_optional_fields.xml"

transmogrifier/sources/ead.py

+2
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def get_optional_fields(self, xml: Tag) -> Optional[dict]:
152152
for id_element in collection_description_did.find_all(
153153
"unitid", recursive=False
154154
):
155+
if id_element.get("type") == "aspace_uri":
156+
continue
155157
if id_value := self.create_string_from_mixed_value(
156158
id_element,
157159
" ",

0 commit comments

Comments
 (0)