Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data: fix responsibilityStatement conversion #1461

Merged
merged 1 commit into from
Nov 19, 2020
Merged
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
4 changes: 2 additions & 2 deletions rero_ils/dojson/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,14 +1502,14 @@ def build_responsibility_data(responsibility_data):
for data_std in data_std_items:
out_data = []
data_value = remove_trailing_punctuation(
data_std.lstrip(), ',.[]', ':;/-=')
data_std.lstrip(), ',.', ':;/-=')
if data_value:
out_data.append({'value': data_value})
if lang:
try:
data_lang_value = \
remove_trailing_punctuation(
data_lang_items[index].lstrip(), ',.[]', ':;/-=')
data_lang_items[index].lstrip(), ',.', ':;/-=')
if not data_lang_value:
raise Exception('missing data')
except Exception as err:
Expand Down
46 changes: 46 additions & 0 deletions tests/unit/test_documents_dojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,52 @@ def test_marc21_to_pid():
assert data.get('pid') is None


def test_marc21_to_title_245_with_sufield_c_having_square_bracket():
"""Test dojson test_marc21_to_title_245_without_246.

- field 245 with subfields $a $b $c
- subfields 245 $a without '='
- subfields 245 $c with '[]'
- field 246 is not present
"""

marc21xml = """
<record>
<controlfield tag=
"008">110729s2011 xx ||| | ||||00| |und d</controlfield>
<datafield tag="035" ind1=" " ind2=" ">
<subfield code="a">R006114538</subfield>
</datafield>
<datafield ind1="0" ind2="0" tag="245">
<subfield code="a">Ma ville en vert :</subfield>
<subfield code="b">pour un retour de la nature /</subfield>
<subfield code="c">[Robert Klant ... [et al.] ; [Kitty B.]</subfield>
</datafield>
</record>
"""
marc21json = create_record(marc21xml)
data = marc21.do(marc21json)
assert data.get('title') == [
{
'type': 'bf:Title',
'mainTitle': [
{'value': 'Ma ville en vert'}
],
'subtitle': [
{'value': 'pour un retour de la nature'}
],
}
]
assert data.get('responsibilityStatement') == [
[
{'value': '[Robert Klant ... [et al.]'}
],
[
{'value': '[Kitty B.]'}
]
]


def test_marc21_to_title_245_with_two_246():
"""Test dojson title with a 245 and two 246.

Expand Down