Esempio n. 1
0
def test_arxiv_categories_from_65017a_2_obsolete_category():
    schema = load_schema('authors')
    subschema = schema['properties']['arxiv_categories']

    snippet = ('<datafield tag="650" ind1="1" ind2="7">'
               '  <subfield code="2">INSPIRE</subfield>'
               '  <subfield code="a">ATOM-PH</subfield>'
               '</datafield>')  # record/1010819

    expected = [
        'physics.atom-ph',
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '2': 'arXiv',
            'a': 'physics.atom-ph',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['65017']
Esempio n. 2
0
def test_inspire_categories_from_65017a_2_E():
    schema = load_schema('authors')
    subschema = schema['properties']['inspire_categories']

    snippet = ('<datafield tag="650" ind1="1" ind2="7">'
               '  <subfield code="2">INSPIRE</subfield>'
               '  <subfield code="a">E</subfield>'
               '</datafield>')  # record/1019112

    expected = [
        {
            'term': 'Experiment-HEP'
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '2': 'INSPIRE',
            'a': 'Experiment-HEP',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['65017']
Esempio n. 3
0
def test_other_names_from_400__triple_a():
    schema = load_schema('authors')
    subschema = schema['properties']['other_names']

    snippet = ('<datafield tag="400" ind1=" " ind2=" ">'
               '  <subfield code="a">Yosef Cohen, Hadar</subfield>'
               '  <subfield code="a">Josef Cohen, Hadar</subfield>'
               '  <subfield code="a">Cohen, Hadar Josef</subfield>'
               '</datafield>')  # record/1292399

    expected = [
        'Yosef Cohen, Hadar',
        'Josef Cohen, Hadar',
        'Cohen, Hadar Josef',
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'Yosef Cohen, Hadar'
        },
        {
            'a': 'Josef Cohen, Hadar'
        },
        {
            'a': 'Cohen, Hadar Josef'
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['400']
Esempio n. 4
0
def test_positions_from_371__a():
    schema = load_schema('authors')
    subschema = schema['properties']['positions']

    snippet = ('<datafield tag="371" ind1=" " ind2=" ">'
               '  <subfield code="a">Aachen, Tech. Hochsch.</subfield>'
               '</datafield>')  # record/997958

    expected = [
        {
            'current': False,
            'institution': {
                'curated_relation': False,
                'name': 'Aachen, Tech. Hochsch.',
            },
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [{'a': 'Aachen, Tech. Hochsch.'}]
    result = hepnames2marc.do(result)

    assert expected == result['371']
Esempio n. 5
0
def test_ids_from_035__a_9_with_orcid():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">ORCID</subfield>'
               '  <subfield code="a">0000-0001-6771-2174</subfield>'
               '</datafield>')

    expected = [
        {
            'schema': 'ORCID',
            'value': '0000-0001-6771-2174',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [{
        '9': 'ORCID',
        'a': '0000-0001-6771-2174',
    }]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 6
0
def test_ids_from_035__a_9_with_wikipedia():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">Wikipedia</subfield>'
               '  <subfield code="a">Guido_Tonelli</subfield>'
               '</datafield>')  # record/985898/export/xme

    expected = [
        {
            'schema': 'WIKIPEDIA',
            'value': 'Guido_Tonelli',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'WIKIPEDIA',
            'a': 'Guido_Tonelli',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 7
0
def test_ids_from_035__a_9_with_scopus():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">SCOPUS</subfield>'
               '  <subfield code="a">7103280792</subfield>'
               '</datafield>')  # record/1017182

    expected = [
        {
            'schema': 'SCOPUS',
            'value': '7103280792',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'SCOPUS',
            'a': '7103280792',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 8
0
def test_stub_from_980__a_useful():
    schema = load_schema('authors')
    subschema = schema['properties']['stub']

    snippet = ('<datafield tag="980" ind1=" " ind2=" ">'
               '  <subfield code="a">USEFUL</subfield>'
               '</datafield>')  # record/1222902

    expected = False
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'USEFUL'
        },
        {
            'a': 'HEPNAMES'
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['980']
Esempio n. 9
0
def test_ids_from_035__a_9_with_viaf():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">VIAF</subfield>'
               '  <subfield code="a">34517183</subfield>'
               '</datafield>')  # record/1008109

    expected = [
        {
            'schema': 'VIAF',
            'value': '34517183',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'VIAF',
            'a': '34517183',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 10
0
def test_ids_from_035__a_9_with_researcherid():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">RESEARCHERID</subfield>'
               '  <subfield code="a">B-4717-2008</subfield>'
               '</datafield>')  # record/1051026

    expected = [
        {
            'schema': 'RESEARCHERID',
            'value': 'B-4717-2008',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'RESEARCHERID',
            'a': 'B-4717-2008',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 11
0
def test_ids_from_035__a_9_with_googlescholar():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">GoogleScholar</subfield>'
               '  <subfield code="a">Tnl-9KoAAAAJ</subfield>'
               '</datafield>')  # record/1467553

    expected = [
        {
            'schema': 'GOOGLESCHOLAR',
            'value': 'Tnl-9KoAAAAJ',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'GOOGLESCHOLAR',
            'a': 'Tnl-9KoAAAAJ',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 12
0
def test_ids_from_035__a_with_bai():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="a">Jian.Long.Han.1</subfield>'
               '</datafield>')  # record/1464894

    expected = [
        {
            'schema': 'INSPIRE BAI',
            'value': 'Jian.Long.Han.1',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'BAI',
            'a': 'Jian.Long.Han.1',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 13
0
def test_ids_from_035__a_9_with_slac():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="9">SLAC</subfield>'
               '  <subfield code="a">SLAC-218626</subfield>'
               '</datafield>')  # record/1028379

    expected = [
        {
            'schema': 'SLAC',
            'value': 'SLAC-218626',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'SLAC',
            'a': 'SLAC-218626',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 14
0
def test_private_notes_from_595__double_a():
    schema = load_schema('authors')
    subschema = schema['properties']['_private_notes']

    snippet = (
        '<datafield tag="595" ind1=" " ind2=" ">'
        '  <subfield code="a">"I want to hide my personal information on REDACTED" 7/2017</subfield>'
        '  <subfield code="a">REDACTED</subfield>'
        '</datafield>')  # record/1279232

    expected = [
        {
            'value':
            '"I want to hide my personal information on REDACTED" 7/2017'
        },
        {
            'value': 'REDACTED'
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': '"I want to hide my personal information on REDACTED" 7/2017'
        },
        {
            'a': 'REDACTED'
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['595']
Esempio n. 15
0
def test_name_from_100__a_g_q():
    schema = load_schema('authors')
    subschema = schema['properties']['name']

    snippet = ('<datafield tag="100" ind1=" " ind2=" ">'
               '  <subfield code="a">Abarbanel, Henry D.I.</subfield>'
               '  <subfield code="q">Henry D.I. Abarbanel</subfield>'
               '  <subfield code="g">ACTIVE</subfield>'
               '</datafield>')  # record/1019100

    expected = {
        'value': 'Abarbanel, Henry D.I.',
        'preferred_name': 'Henry D.I. Abarbanel',
    }
    result = hepnames.do(create_record(snippet))

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

    expected = {
        'a': 'Abarbanel, Henry D.I.',
        'q': 'Henry D.I. Abarbanel',
        'g': 'active',
    }
    result = hepnames2marc.do(result)

    assert expected == result['100']
Esempio n. 16
0
def test_ids_from_970__a():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="970" ind1=" " ind2=" ">'
               '  <subfield code="a">HEPNAMES-646482</subfield>'
               '</datafield>')  # record/1498151

    expected = [
        {
            'schema': 'SPIRES',
            'value': 'HEPNAMES-646482',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'HEPNAMES-646482'
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['970']
Esempio n. 17
0
def test_name_from_100__g_q_populates_value_from_preferred_name():
    schema = load_schema('authors')
    subschema = schema['properties']['name']

    snippet = ('<datafield tag="100" ind1=" " ind2=" ">'
               '  <subfield code="g">ACTIVE</subfield>'
               '  <subfield code="q">Vyacheslav I. Yukalova</subfield>'
               '</datafield>')  # record/1259075

    expected = {
        'preferred_name': 'Vyacheslav I. Yukalova',
        'value': 'Yukalova, Vyacheslav I.',
    }
    result = hepnames.do(create_record(snippet))

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

    expected = {
        'a': 'Yukalova, Vyacheslav I.',
        'g': 'active',
        'q': 'Vyacheslav I. Yukalova',
    }
    result = hepnames2marc.do(result)

    assert expected == result['100']
Esempio n. 18
0
def test_deleted_from_980__c():
    schema = load_schema('authors')
    subschema = schema['properties']['deleted']

    snippet = ('<datafield tag="980" ind1=" " ind2=" ">'
               '  <subfield code="c">DELETED</subfield>'
               '</datafield>')  # record/1511071

    expected = True
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'c': 'DELETED'
        },
        {
            'a': 'HEPNAMES'
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['980']
Esempio n. 19
0
def test_title_from_100__a_c_q_discards_default_title():
    schema = load_schema('authors')
    subschema = schema['properties']['name']

    snippet = ('<datafield tag="100" ind1=" " ind2=" ">'
               '  <subfield code="a">Joosten, Sylvester Johannes</subfield>'
               '  <subfield code="c">title (e.g. Sir)</subfield>'
               '  <subfield code="q">Sylvester Johannes Joosten</subfield>'
               '</datafield>')  # record/1270441

    expected = {
        'preferred_name': 'Sylvester Johannes Joosten',
        'value': 'Joosten, Sylvester Johannes',
    }
    result = hepnames.do(create_record(snippet))

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

    expected = {
        'a': 'Joosten, Sylvester Johannes',
        'q': 'Sylvester Johannes Joosten',
    }
    result = hepnames2marc.do(result)

    assert expected == result['100']
Esempio n. 20
0
def test_ids_from_035__a_9_with_desy():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = ('<datafield tag="035" ind1=" " ind2=" ">'
               '  <subfield code="a">DESY-1001805</subfield>'
               '  <subfield code="9">DESY</subfield>'
               '</datafield>')  # record/993224/export/xme

    expected = [
        {
            'schema': 'DESY',
            'value': 'DESY-1001805',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'DESY',
            'a': 'DESY-1001805',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
Esempio n. 21
0
def test_private_notes_from_595__a_9():
    schema = load_schema('authors')
    subschema = schema['properties']['_private_notes']

    snippet = (
        '<datafield tag="595" ind1=" " ind2=" ">'
        '  <subfield code="a">Author prefers Alexandrov, A.S.</subfield>'
        '  <subfield code="9">SPIRES-HIDDEN</subfield>'
        '</datafield>')  # record/1050484

    expected = [{
        'source': 'SPIRES-HIDDEN',
        'value': 'Author prefers Alexandrov, A.S.',
    }]
    result = hepnames.do(create_record(snippet))

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

    expected = [{
        '9': 'SPIRES-HIDDEN',
        'a': 'Author prefers Alexandrov, A.S.',
    }]
    result = hepnames2marc.do(result)

    assert expected == result['595']
Esempio n. 22
0
def test_acquisition_source_from_541__a_b_c_d_e_converts_dates_to_datetimes():
    schema = load_schema('authors')
    subschema = schema['properties']['acquisition_source']

    snippet = ('<datafield tag="541" ind1=" " ind2=" ">'
               '  <subfield code="a">inspire:uid:51852</subfield>'
               '  <subfield code="b">[email protected]</subfield>'
               '  <subfield code="c">submission</subfield>'
               '  <subfield code="d">2016-05-24</subfield>'
               '  <subfield code="e">805819</subfield>'
               '</datafield>')  # record/982806

    expected = {
        'datetime': '2016-05-24T00:00:00',
        'email': '*****@*****.**',
        'internal_uid': 51852,
        'method': 'submitter',
        'submission_number': '805819',
    }
    result = hepnames.do(create_record(snippet))

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

    expected = {
        'b': '*****@*****.**',
        'c': 'submission',
        'd': '2016-05-24T00:00:00',
        'e': '805819',
    }
    result = hepnames2marc.do(result)

    assert expected == result['541']
Esempio n. 23
0
def test_old_single_email_from_371__a():
    schema = load_schema('authors')
    subschema = schema['properties']['positions']

    snippet = (
        '<datafield tag="371" ind1=" " ind2=" ">'
        '   <subfield code="a">IMSc, Chennai</subfield>'
        '   <subfield code="o">[email protected]</subfield>'
        '   <subfield code="r">PD</subfield>'
        '   <subfield code="s">2012</subfield>'
        '   <subfield code="t">2013</subfield>'
        '</datafield>'
    )  # record/1060782

    expected = [
        {
            "current": False,
            "old_emails": [
                "*****@*****.**"
            ],
            "end_date": "2013",
            "rank": "POSTDOC",
            "institution": {
                "name": "IMSc, Chennai",
                "curated_relation": False
            },
            "_rank": "PD",
            "start_date": "2012"
        }
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            "a": "IMSc, Chennai",
            "o": [
                "*****@*****.**"
            ],
            "s": "2012",
            "r": "PD",
            "t": "2013"
        }
    ]
    result = hepnames2marc.do(result)

    assert expected == result['371']
Esempio n. 24
0
def test_ids_from_double_035__a_9():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = (
        '<record>'
        '  <datafield tag="035" ind1=" " ind2=" ">'
        '    <subfield code="a">INSPIRE-00134135</subfield>'
        '    <subfield code="9">INSPIRE</subfield>'
        '  </datafield>'
        '  <datafield tag="035" ind1=" " ind2=" ">'
        '    <subfield code="a">H.Vogel.1</subfield>'
        '    <subfield code="9">BAI</subfield>'
        '  </datafield>'
        '</record>'
    )  # record/984519

    expected = [
        {
            'schema': 'INSPIRE ID',
            'value': 'INSPIRE-00134135',
        },
        {
            'schema': 'INSPIRE BAI',
            'value': 'H.Vogel.1',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'INSPIRE-00134135',
            '9': 'INSPIRE'
        },
        {
            'a': 'H.Vogel.1',
            '9': 'BAI'
        }
    ]
    result = hepnames2marc.do(result)

    for el in expected:
        assert el in result['035']
    for el in result['035']:
        assert el in expected
Esempio n. 25
0
def test_experiments(mock_get_record_ref, mock_get_recid_from_ref, test_name,
                     xml_snippet, expected_json, expected_marc):
    mock_get_record_ref.side_effect = \
        lambda x, *_: x and 'mocked_recid_%s' % x
    mock_get_recid_from_ref.side_effect = \
        lambda x, *_: x and int(x.rsplit('_')[-1])

    if not xml_snippet.strip().startswith('<record>'):
        xml_snippet = '<record>%s</record>' % xml_snippet

    json_data = hepnames.do(create_record(xml_snippet))
    json_experiments = json_data['experiments']
    marc_experiments = hepnames2marc.do(json_data)['693']

    assert marc_experiments == expected_marc
    assert json_experiments == expected_json
Esempio n. 26
0
def test_advisors_from_701__a_g_i():
    schema = load_schema('authors')
    subschema = schema['properties']['advisors']

    snippet = (
        '<datafield tag="701" ind1=" " ind2=" ">'
        '  <subfield code="a">Rivelles, Victor O.</subfield>'
        '  <subfield code="g">PhD</subfield>'
        '  <subfield code="i">INSPIRE-00120420</subfield>'
        '  <subfield code="x">991627</subfield>'
        '  <subfield code="y">1</subfield>'
        '</datafield>'
    )  # record/1474091/export/xme

    expected = [
        {
            'name': 'Rivelles, Victor O.',
            'degree_type': 'PhD',
            'ids': [
                {
                    'schema': 'INSPIRE ID',
                    'value': 'INSPIRE-00120420'
                }
            ],
            'record': {
                '$ref': 'http://localhost:5000/api/authors/991627',
            },
            'curated_relation': True
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'Rivelles, Victor O.',
            'g': 'PhD',
            'i': 'INSPIRE-00120420',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['701']
Esempio n. 27
0
def test_ids_from_double_035__a_9_with_kaken():
    schema = load_schema('authors')
    subschema = schema['properties']['ids']

    snippet = (
        '<record>'
        '  <datafield tag="035" ind1=" " ind2=" ">'
        '    <subfield code="9">BAI</subfield>'
        '    <subfield code="a">Toshio.Suzuki.2</subfield>'
        '  </datafield>'
        '  <datafield tag="035" ind1=" " ind2=" ">'
        '    <subfield code="9">KAKEN</subfield>'
        '    <subfield code="a">70139070</subfield>'
        '  </datafield>'
        '</record>'
    )  # record/1474271/export/xme

    expected = [
        {
            'schema': 'INSPIRE BAI',
            'value': 'Toshio.Suzuki.2',
        },
        {
            'schema': 'KAKEN',
            'value': 'KAKEN-70139070',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            '9': 'BAI',
            'a': 'Toshio.Suzuki.2',
        },
        {
            '9': 'KAKEN',
            'a': 'KAKEN-70139070',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['035']
def test_new_record_from_970__d():
    schema = load_schema('authors')
    subschema = schema['properties']['new_record']

    snippet = ('<datafield tag="970" ind1=" " ind2=" ">'
               '  <subfield code="d">1039458</subfield>'
               '</datafield>')  # record/1271254

    expected = {'$ref': 'http://localhost:5000/api/authors/1039458'}
    result = hepnames.do(create_record(snippet))

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

    expected = {'d': 1039458}
    result = hepnames2marc.do(result)

    assert expected == result['970']
Esempio n. 29
0
def test_legacy_creation_date_from_961__double_x_does_not_raise():
    schema = load_schema('authors')
    subschema = schema['properties']['legacy_creation_date']

    snippet = ('<datafield tag="961" ind1=" " ind2=" ">'
               '  <subfield code="x">2006-04-21</subfield>'
               '  <subfield code="x">1996-09-01</subfield>'
               '</datafield>')  # record/982164

    expected = '1996-09-01'
    result = hepnames.do(create_record(snippet))

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

    expected = {'x': '1996-09-01'}
    result = hepnames2marc.do(result)

    assert expected == result['961']
Esempio n. 30
0
def test_positions_from_371__a_r_t_z():
    schema = load_schema('authors')
    subschema = schema['properties']['positions']

    snippet = (
        '<datafield tag="371" ind1=" " ind2=" ">'
        '  <subfield code="a">San Luis Potosi U.</subfield>'
        '  <subfield code="r">Master</subfield>'
        '  <subfield code="t">2007</subfield>'
        '  <subfield code="z">903830</subfield>'
        '</datafield>'
    )  # record/1037568

    expected = [
        {
            '_rank': 'Master',
            'current': False,
            'end_date': '2007',
            'institution': {
                'curated_relation': True,
                'name': 'San Luis Potosi U.',
                'record': {
                    '$ref': 'http://localhost:5000/api/institutions/903830',
                },
            },
            'rank': 'MASTER',
        },
    ]
    result = hepnames.do(create_record(snippet))

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

    expected = [
        {
            'a': 'San Luis Potosi U.',
            'r': 'MAS',
            't': '2007',
        },
    ]
    result = hepnames2marc.do(result)

    assert expected == result['371']