Skip to content

Commit

Permalink
tests: add tests for 242 field
Browse files Browse the repository at this point in the history
Signed-off-by: Spiros Delviniotis <spyridon.delviniotis@cern.ch>
  • Loading branch information
spirosdelviniotis committed Feb 2, 2017
1 parent 0963289 commit ea91f8e
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/unit/dojson/test_dojson_hep.py
Expand Up @@ -2074,3 +2074,68 @@ def test_title_from_245_and_247__a_9():
result = hep2marc.do(result)

assert expected == result['245']


def test_title_from_242__a():
schema = load_schema('hep')
subschema = schema['properties']['title_translations']

snippet = (
'<datafield tag="242" ind1=" " ind2=" ">'
' <subfield code="a">The redshift of extragalactic nebulae</subfield>'
'</datafield>'
) # record/8352

expected = [
{
'title': 'The redshift of extragalactic nebulae',
'language': 'en',
},
]
result = hep.do(create_record(snippet))

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

expected = [
{
'a': 'The redshift of extragalactic nebulae',
},
]
result = hep2marc.do(result)

assert expected == result['242']


def test_title_from_242__a_b():
schema = load_schema('hep')
subschema = schema['properties']['title_translations']

snippet = (
'<datafield tag="242" ind1=" " ind2=" ">'
' <subfield code="a">Generalized Hamilton-Jacobi Formalism</subfield>'
' <subfield code="b">Field Theories with Upper-Order Derivatives</subfield>'
'</datafield>'
) # record/1501064

expected = [
{
'title': 'Generalized Hamilton-Jacobi Formalism',
'subtitle': 'Field Theories with Upper-Order Derivatives',
'language': 'en',
},
]
result = hep.do(create_record(snippet))

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

expected = [
{
'a': 'Generalized Hamilton-Jacobi Formalism',
'b': 'Field Theories with Upper-Order Derivatives',
},
]
result = hep2marc.do(result)

assert expected == result['242']

0 comments on commit ea91f8e

Please sign in to comment.