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']
def test_create_viaf_record(app, viaf_record): """Test create Viaf record.""" 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_auth_pid'] == 'A023655346'
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