Skip to content

Commit

Permalink
marc21: ignore oaiset fields
Browse files Browse the repository at this point in the history
* Adds oaiset fields. (closes #78)

Signed-off-by: Leonardo Rossi <leonardo.r@cern.ch>
  • Loading branch information
Leonardo Rossi authored and egabancho committed Jul 14, 2017
1 parent 07abedd commit a2f5392
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
2 changes: 1 addition & 1 deletion cds_dojson/marc21/fields/videos/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def language_to_isocode(lang):
lang = lang.lower()
try:
return pycountry.languages.get(alpha_3=lang).alpha_2
except KeyError, AttributeError:
except (KeyError, AttributeError):
exceptions = {
'eng-fre': 'en-fr',
'silent': 'silent',
Expand Down
5 changes: 4 additions & 1 deletion cds_dojson/marc21/models/videos/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class CDSVideo(OverdoJSONSchema):

__schema__ = 'records/videos/video/video-v1.0.0.json'

__ignore_keys__ = {'035__9', '035__a', '5061_2', '5061_5', '5061_a'}
__ignore_keys__ = {
'035__9', '035__a', '5061_2', '5061_5', '5061_a', '0248_a', '0248_p',
'0248_q',
}


model = CDSVideo(bases=(cds_base, ),
Expand Down
7 changes: 6 additions & 1 deletion tests/fixtures/videos_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<record>
<controlfield tag="001">2272973</controlfield>
<controlfield tag="005">20170704112045.0</controlfield>
<datafield tag="0248" ind1=" " ind2=" ">
<subfield code="a">test a</subfield>
<subfield code="p">test p</subfield>
<subfield code="q">test q</subfield>
</datafield>
<datafield tag="037" ind1=" " ind2=" ">
<subfield code="a">CERN-MOVIE-2017-023-001</subfield>
</datafield>
Expand Down Expand Up @@ -50,7 +55,7 @@
<subfield code="m">example@test.com</subfield>
</datafield>
<datafield tag="520" ind1=" " ind2=" ">
<subfield code="a">Where were you on 4 July 2012, the day in which the Higgs boson discovery was announced? Many people will be able to answer without referring to their diary. Perhaps you were among the few who had managed to secure a seat in CERN’s main auditorium, or who joined colleagues in universities and laboratories around the world at odd times of the day to watch the webcast. “I think we have it, no?” was the question posed by the then CERN Director General Rolf Heuer on 4 July in the CERN auditorium. The answer was as obvious as the emotion on faces in the crowd. The then ATLAS and CMS spokespersons, Fabiola Gianotti and Joe Incandela, had just presented the latest Higgs search results based on roughly two years of LHC operations. Given the hints for the Higgs presented a few months earlier in December 2011, the frenzy of rumours on blogs and intense media interest during the preceding weeks, and a title for the CERN seminar that left little to the imagination, the outcome was anticipated. This did not temper excitement.</subfield>
<subfield code="a">Where were you on 4 July 2012, the day in which the Higgs boson discovery was announced?</subfield>
</datafield>
<datafield tag="542" ind1=" " ind2=" ">
<subfield code="d">CERN</subfield>
Expand Down
79 changes: 44 additions & 35 deletions tests/test_videos_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,50 @@ def test_required_fields(app):
blob = create_record(marcxml)
record = model.do(blob)

assert record['$schema'] == {
'$ref': ('https://cds.cern.ch/schemas/records/videos/video/'
'video-v1.0.0.json')
assert record == {
'$schema': {
'$ref': ('https://cds.cern.ch/schemas/records/videos/video/'
'video-v1.0.0.json')
},
'_access': {'read': ['test-group@cern.ch',
'cds-admin@cern.ch',
'test-email@cern.ch',
'example@test.com'],
'update': ['Jacques.Fichet@cern.ch',
'christoph.martin.madsen@cern.ch']},
'category': 'CERN',
'contributors': [
{'name': 'CERN Video Productions', 'role': 'Producer'},
{'name': 'CERN Video Productions', 'role': 'Director'},
{'affiliations': (u'CERN',),
'email': u'christoph.martin.madsen@cern.ch',
'ids': [{'source': 'CERN', 'value': u'755568'},
{'source': 'CDS', 'value': u'2090563'}],
'name': 'Madsen, Christoph Martin',
'role': 'Director'},
{'affiliations': (u'CERN',),
'email': u'Paola.Catapano@cern.ch',
'ids': [{'source': 'CERN', 'value': u'380837'},
{'source': 'CDS', 'value': u'2050975'}],
'name': 'Catapano, Paola',
'role': 'Director'},
{'affiliations': (u'CERN',),
'email': u'christoph.martin.madsen@cern.ch',
'ids': [{'source': 'CERN', 'value': u'755568'},
{'source': 'CDS', 'value': u'2090563'}],
'name': 'Madsen, Christoph Martin',
'role': 'Editor'}],
'date': '2017-07-04',
'description': ('Where were you on 4 July 2012, the day in which '
'the Higgs boson discovery was announced?'),
'duration': '00:01:09',
'language': u'en',
'modification_date': '20170704112045.0',
'recid': 2272973,
'report_number': ['CERN-MOVIE-2017-023-001'],
'title': {'title': 'Happy 5th anniversary, Higgs boson!'},
'type': 'MOVIE'
}
assert record['recid'] == 2272973
assert record['date'] == '2017-07-04'
assert record['duration'] == '00:01:09'
assert record['title'][
'title'] == 'Happy 5th anniversary, Higgs boson!'
assert record['contributors'][0] == {
'name': u'CERN Video Productions',
'role': 'Producer'
}
assert record['contributors'][-1] == {
'affiliations': ('CERN', ),
'email': 'christoph.martin.madsen@cern.ch',
'ids': [
{'source': 'CERN', 'value': u'755568'},
{'source': 'CDS', 'value': u'2090563'}
],
'name': 'Madsen, Christoph Martin',
'role': 'Editor'
}
assert record['_access'] == {
'read': [
'test-group@cern.ch',
'cds-admin@cern.ch',
'test-email@cern.ch',
'example@test.com',
],
'update': [
'Jacques.Fichet@cern.ch',
'christoph.martin.madsen@cern.ch',
]
}
assert record['language'] == 'en'

# Add required fields calculated by post-process tasks.
record['publication_date'] = '2017-07-04'
Expand All @@ -82,3 +90,4 @@ def test_language_to_isocode():
assert language_to_isocode('silent') == 'silent'
assert language_to_isocode('sil') == 'silent'
assert language_to_isocode('fuu') is None
assert language_to_isocode('test >3 chars') is None

0 comments on commit a2f5392

Please sign in to comment.