def test_contribution_mef_create(mock_contributions_mef_get, app,
                                 contribution_person_data_tmp,
                                 contribution_person_response_data):
    """Test MEF contribution creation."""
    count = Contribution.count()
    mock_contributions_mef_get.return_value = mock_response(
        json_data=contribution_person_response_data)
    pers_mef, online = Contribution.get_record_by_ref(
        'https://mef.rero.ch/api/rero/A017671081')
    flush_index(ContributionsSearch.Meta.index)
    assert pers_mef == contribution_person_data_tmp
    assert online
    assert Contribution.count() == count + 1
    pers_mef.pop('idref')
    pers_mef['sources'] = ['gnd']
    pers_mef.replace(pers_mef, dbcommit=True)
    pers_db, online = Contribution.get_record_by_ref(
        'https://mef.rero.ch/api/gnd/13343771X')
    assert pers_db['sources'] == ['gnd']
    assert not online
Exemple #2
0
def test_publish_api_harvested_records(app, contribution_person_data_tmp,
                                       capsys):
    """Test mef contribution publish api harvested records."""
    publish_api_harvested_records(sender='test',
                                  name='mef',
                                  records=[contribution_person_data_tmp],
                                  url='http://test.com')
    out, err = capsys.readouterr()
    assert out.strip() == (
        'mef harvester: received 1 records: '
        'https://ils.rero.ch/schemas/contributions/contribution-v0.0.1.json')
    assert Contribution.count() == 1