Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,28 @@ def title(self, key, value):
title = StringValue(value.get("a"))
subtitle = StringValue(value.get("b", "")).parse()
title.required()
title_string = title.parse()
alt_titles = self.get("additional_titles", [])
if subtitle:
alt_titles = self.get("additional_titles", [])
alt_titles.append(
{
"title": subtitle,
"type": {"id": "subtitle"},
}
)
self["additional_titles"] = alt_titles
return title.parse()
if self.get("title") and title_string:
alt_titles.append(
{
"title": title_string,
"type": {"id": "subtitle"},
}
)
self["additional_titles"] = alt_titles
raise IgnoreKey("title")
if title_string:
return title_string
raise IgnoreKey("title")


@model.over("rights", "^540__")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,7 @@ def title(self, key, value):
self["additional_titles"] = alt_titles
identifiers = self.get("identifiers", [])
rep_num = next(
(
identifier
for identifier in identifiers
if identifier["scheme"] == "cdsrn"
),
(identifier for identifier in identifiers if identifier["scheme"] == "cdsrn"),
{},
).get("identifier")

Expand All @@ -393,7 +389,6 @@ def title(self, key, value):
return title



@model.over("meeting_cf", "^773__")
@for_each_value
def meeting(self, key, value):
Expand Down
9 changes: 4 additions & 5 deletions tests/cds-rdm/test_base_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ def test_title_with_subtitle(self):
def test_title_missing_field_returns_empty(self):
"""Test that missing title returns empty string."""
record = {}
result = title(record, "245__", {})
# StringValue with empty value returns empty string
assert result == ""
with pytest.raises(IgnoreKey):
title(record, "245__", {})

def test_title_empty_string_returns_empty(self):
"""Test that empty title returns empty string."""
record = {}
result = title(record, "245__", {"a": ""})
assert result == ""
with pytest.raises(IgnoreKey):
title(record, "245__", {"a": ""})

def test_title_subtitle_appends_to_existing(self):
"""Test subtitle appends to existing additional_titles."""
Expand Down
Loading