def test_harvest_fundref(app, db, es): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(source='tests/testdata/fundref_test.rdf') print(PersistentIdentifier.query.all()) assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5
def test_harvest_fundref(app, db): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(path='tests/testdata/fundref_test.rdf') print(PersistentIdentifier.query.all()) assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5
def test_harvest_all(app): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 5 assert RecordMetadata.query.count() == 5 harvest_openaire_projects(path='tests/testdata/openaire_test.sqlite') assert PersistentIdentifier.query.count() == 45 assert RecordMetadata.query.count() == 15
def test_harvest_all(app, db): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 harvest_openaire_projects(path='tests/testdata/openaire_test.sqlite') assert PersistentIdentifier.query.count() == 46 assert RecordMetadata.query.count() == 15
def test_harvest_all(app, db): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(source="tests/testdata/fundref_test.rdf") assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 harvest_openaire_projects(source="tests/testdata/openaire_test.sqlite") assert PersistentIdentifier.query.count() == 46 assert RecordMetadata.query.count() == 15
def indexed_records(app, es, db): """Provide elasticsearch access.""" harvest_openaire_projects(path='tests/testdata/openaire_test.sqlite') harvest_fundref(path='tests/testdata/fundref_test.rdf') records = [] for record in RecordMetadata.query.all(): records.append(record.id) RecordIndexer().index_by_id(record.id) es.flush_and_refresh('_all') yield records
def test_reharvest_fundref(app, db, es): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(source='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 recid = PersistentIdentifier.query.first().object_uuid record = Record.get_record(recid) record['title'] = 'Foobar' record.commit() db.session.commit() harvest_fundref(source='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 record = Record.get_record(recid) assert record['remote_modified'] != 'Foobar'
def test_reharvest_fundref(app): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 5 assert RecordMetadata.query.count() == 5 recid = PersistentIdentifier.query.first().object_uuid test_date = "2002-01-01T16:00:00.000000" record = Record.get_record(recid) record['remote_modified'] = test_date record.commit() db.session.commit() harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 5 assert RecordMetadata.query.count() == 5 record = Record.get_record(recid) assert record['remote_modified'] != test_date
def test_reharvest_fundref(app, db): """Test harvest_openaire_projects.""" with app.app_context(): harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 recid = PersistentIdentifier.query.first().object_uuid test_date = "2002-01-01T16:00:00.000000" record = Record.get_record(recid) record['remote_modified'] = test_date record.commit() db.session.commit() harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 6 assert RecordMetadata.query.count() == 5 record = Record.get_record(recid) assert record['remote_modified'] != test_date
def test_records_rest(app, es): """Test Records REST.""" app.config['RECORDS_REST_ENDPOINTS'] = OPENAIRE_REST_ENDPOINTS try: InvenioRecordsREST(app) except TypeError: # Temporary support Invenio-Records-REST v1.0.0a4 del app.config['RECORDS_REST_ENDPOINTS']['frdoi']['default_media_type'] del app.config['RECORDS_REST_ENDPOINTS']['grant']['default_media_type'] InvenioRecordsREST(app) harvest_openaire_projects(path='tests/testdata/openaire_test.sqlite') harvest_fundref(path='tests/testdata/fundref_test.rdf') assert PersistentIdentifier.query.count() == 45 with app.test_client() as client: res = client.get("/funders/10.13039/001") assert res.status_code == 200 res = client.get("/funders/") assert res.status_code == 200 res = client.get("/grants/10.13039/501100000923::LP0667725") assert res.status_code == 200 res = client.get("/grants/") assert res.status_code == 200
def funders(app, es, db): """Funder records fixture.""" harvest_fundref(source='tests/testdata/fundref_test.rdf')
InvenioDB(app) InvenioRecords(app) InvenioCelery(app) InvenioPIDStore(app) InvenioOpenAIRE(app) InvenioJSONSchemas(app) app.config.update( TESTING=True, SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://postgres:postgres@localhost' '/invenio_test', CELERY_ALWAYS_EAGER=True, BROKER_URL='redis://*****:*****@localhost:5672//', # CELERY_ACCEPT_CONTENT=['json', 'msgpack', 'yaml'], # CELERY_RESULT_SERIALIZER='msgpack', # CELERY_TASK_SERIALIZER='msgpack', ) # celery_ext = InvenioCelery(app) celery = create_celery_app(app) if __name__ == "__main__": with app.app_context(): if database_exists(str(db.engine.url)): drop_database(str(db.engine.url)) create_database(str(db.engine.url)) db.create_all() harvest_fundref() harvest_openaire_projects()
def load_funders_testdata(): """Load the funders test data.""" testdir = os.path.dirname(__file__) source = os.path.join(testdir, 'testdata/fundref_test.rdf') harvest_fundref(source=source)
def load_funders_testdata(): """Load the funders test data.""" testdir = os.path.dirname(__file__) source = os.path.join(testdir, 'testdata/fundref_test.rdf') harvest_fundref(path=source)
FlaskCLI(app) InvenioDB(app) InvenioRecords(app) InvenioCelery(app) InvenioPIDStore(app) InvenioOpenAIRE(app) InvenioJSONSchemas(app) app.config.update( TESTING=True, SQLALCHEMY_DATABASE_URI='postgresql+psycopg2://postgres:postgres@localhost' '/invenio_test', CELERY_ALWAYS_EAGER=True, BROKER_URL='redis://*****:*****@localhost:5672//', # CELERY_ACCEPT_CONTENT=['json', 'msgpack', 'yaml'], # CELERY_RESULT_SERIALIZER='msgpack', # CELERY_TASK_SERIALIZER='msgpack', ) # celery_ext = InvenioCelery(app) celery = create_celery_app(app) if __name__ == "__main__": with app.app_context(): if database_exists(str(db.engine.url)): drop_database(str(db.engine.url)) create_database(str(db.engine.url)) db.create_all() harvest_fundref() harvest_openaire_projects()