示例#1
0
def test_create_agency_record_with_viaf_links(
        app, viaf_record, bnf_record, gnd_record, rero_record):
    """Test create agency record with viaf links."""
    returned_bnf_record, bnf_status = BnfRecord.create_or_update(
        bnf_record, agency='bnf', dbcommit=True, reindex=True
    )
    update_indexes('bnf')
    update_indexes('mef')
    assert bnf_status == 'create'
    assert returned_bnf_record['pid'] == '10000690'

    returned_gnd_record, gnd_status = GndRecord.create_or_update(
        gnd_record, agency='gnd', dbcommit=True, reindex=True
    )
    update_indexes('gnd')
    update_indexes('mef')
    assert gnd_status == 'create'
    assert returned_gnd_record['pid'] == '12391664X'

    returned_rero_record, rero_status = ReroRecord.create_or_update(
        rero_record, agency='rero', dbcommit=True, reindex=True
    )
    update_indexes('rero')
    update_indexes('mef')
    assert rero_status == 'create'
    assert returned_rero_record['pid'] == 'A023655346'
示例#2
0
def test_create_mef_from_agency_with_viaf_links(
        app, viaf_record, bnf_record, gnd_record):
    """Test create MEF record from agency with viaf links."""
    returned_record, status = ViafRecord.create_or_update(
        viaf_record, agency='viaf', dbcommit=True, reindex=True
    )
    update_indexes('viaf')
    assert status == 'create'
    assert returned_record['viaf_pid'] == '66739143'
    assert returned_record['bnf_pid'] == '10000690'
    assert returned_record['gnd_pid'] == '12391664X'
    assert returned_record['rero_pid'] == 'A023655346'

    returned_bnf_record, bnf_status = BnfRecord.create_or_update(
        bnf_record, agency='bnf', dbcommit=True, reindex=True
    )
    update_indexes('bnf')
    update_indexes('mef')
    assert bnf_status == 'create'
    assert returned_bnf_record['pid'] == '10000690'

    returned_gnd_record, gnd_status = GndRecord.create_or_update(
        gnd_record, agency='gnd', dbcommit=True, reindex=True
    )
    update_indexes('gnd')
    update_indexes('mef')
    assert gnd_status == 'create'
    assert returned_gnd_record['pid'] == '12391664X'

    key = '{agency}{identifier}'.format(agency='bnf', identifier='.pid')
    result = MefSearch().filter(
        'term', **{key: '10000690'}).source().scan()
    sources = [n['sources'] for n in result]
    assert sources[0] == ['gnd', 'bnf']
示例#3
0
def test_create_agency_record_no_viaf_links(
        app, bnf_record, gnd_record, rero_record):
    """Test create agency record without viaf links."""
    returned_record, status = BnfRecord.create_or_update(
        bnf_record, agency='bnf', dbcommit=True, reindex=True
    )
    update_indexes('bnf')
    update_indexes('mef')
    assert status == 'discard'
    assert returned_record == {}

    returned_record, status = GndRecord.create_or_update(
        gnd_record, agency='gnd', dbcommit=True, reindex=True
    )
    update_indexes('gnd')
    update_indexes('mef')
    assert status == 'discard'
    assert returned_record == {}

    returned_record, status = ReroRecord.create_or_update(
        rero_record, agency='rero', dbcommit=True, reindex=True
    )
    update_indexes('rero')
    update_indexes('mef')
    assert status == 'discard'
    assert returned_record == {}
示例#4
0
def test_ref_resolvers(app, bnf_record, gnd_record, rero_record, viaf_record):
    """Test ref resolvers."""
    """VIAF record."""
    viaf_rec, status = ViafRecord.create_or_update(viaf_record,
                                                   agency='viaf',
                                                   dbcommit=True,
                                                   reindex=True)
    viaf_pid = viaf_rec['viaf_pid']
    current_search.flush_and_refresh(index='authorities-viaf-person-v0.0.1')
    current_search.flush_and_refresh(index='authorities-mef-person-v0.0.1')
    """BNF record."""
    bnf_rec, status = BnfRecord.create_or_update(bnf_record,
                                                 agency='bnf',
                                                 dbcommit=True,
                                                 reindex=True)
    current_search.flush_and_refresh(index='authorities-bnf-person-v0.0.1')
    current_search.flush_and_refresh(index='authorities-mef-person-v0.0.1')
    bnf_pid = bnf_rec['identifier_for_person']
    """GND record."""
    gnd_rec, status = GndRecord.create_or_update(gnd_record,
                                                 agency='gnd',
                                                 dbcommit=True,
                                                 reindex=True)
    current_search.flush_and_refresh(index='authorities-gnd-person-v0.0.1')
    current_search.flush_and_refresh(index='authorities-mef-person-v0.0.1')
    gnd_pid = gnd_rec.get('identifier_for_person')
    """RERO record."""
    rero_rec, status = ReroRecord.create_or_update(rero_record,
                                                   agency='rero',
                                                   dbcommit=True,
                                                   reindex=True)
    current_search.flush_and_refresh(index='authorities-rero-person-v0.0.1')
    rero_pid = rero_rec.get('identifier_for_person')
    current_search.flush_and_refresh(index='authorities-mef-person-v0.0.1')
    """MEF record."""
    mef_rec_resolved = MefRecord.get_mef_by_viaf_pid(viaf_pid=viaf_pid)
    mef_rec_resolved = mef_rec_resolved.replace_refs()
    assert mef_rec_resolved.get('bnf').get('identifier_for_person') == bnf_pid
    assert mef_rec_resolved.get('gnd').get('identifier_for_person') == gnd_pid
    assert mef_rec_resolved.get('rero').get(
        'identifier_for_person') == rero_pid