Skip to content

Commit

Permalink
Merge pull request #1970 from jacquerie/bump-schemas-to-version-27
Browse files Browse the repository at this point in the history
global: bump inspire-schemas to version ~27.0
  • Loading branch information
jacquerie authored Mar 3, 2017
2 parents e91f0b0 + 4000831 commit b52a7f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
13 changes: 7 additions & 6 deletions inspirehep/dojson/hep/rules/bd2xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,17 @@ def get_transformed_title(val):
return [get_transformed_title(value) for value in values]


@hep.over('edition', '^250..')
@hep.over('editions', '^250..')
@utils.flatten
@utils.for_each_value
def edition(self, key, value):
return {'edition': value.get('a')}
def editions(self, key, value):
return force_force_list(value.get('a'))


@hep2marc.over('250', 'edition')
@hep2marc.over('250', '^editions$')
@utils.for_each_value
def edition2marc(self, key, value):
return {'a': value.get('edition')}
def editions2marc(self, key, value):
return {'a': value}


@hep.over('imprints', '^260[_23].')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'invenio-utils==0.2.0', # Not fully Invenio 3 ready
'invenio>=3.0.0a1,<3.1.0',
'inspire-crawler~=0.2.7',
'inspire-schemas~=26.0',
'inspire-schemas~=27.0',
'dojson>=1.3.0',
'Flask>=0.11.1',
'Flask-Breadcrumbs>=0.3.0',
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/dojson/test_dojson_hep_bd2xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,29 @@ def test_title_translations_from_242__a_b():
result = hep2marc.do(result)

assert expected == result['242']


def test_editions_from_250__a():
schema = load_schema('hep')
subschema = schema['properties']['editions']

snippet = (
'<datafield tag="250" ind1=" " ind2=" ">'
' <subfield code="a">2nd ed.</subfield>'
'</datafield>'
) # record/1383727

expected = [
'2nd ed.',
]
result = hep.do(create_record(snippet))

assert validate(result['editions'], subschema) is None
assert expected == result['editions']

expected = [
{'a': '2nd ed.'},
]
result = hep2marc.do(result)

assert expected == result['250']

0 comments on commit b52a7f6

Please sign in to comment.