def test_harvest_openaire_projects(app, db, es, funders): """Test harvest_openaire_projects.""" with app.app_context(): # Use local OpenAIRE loader harvest_openaire_projects(source='tests/testdata/openaire_test.sqlite') assert PersistentIdentifier.query.count() == 46 assert RecordMetadata.query.count() == 15
def test_harvest_openaire_projects(app): """Test harvest_openaire_projects.""" with app.app_context(): # Use local OpenAIRE loader harvest_openaire_projects(path='tests/testdata/openaire_test.sqlite') assert PersistentIdentifier.query.count() == 40 assert RecordMetadata.query.count() == 10
def test_harvest_all(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 harvest_openaire_projects(source='tests/testdata/openaire_test.sqlite') assert PersistentIdentifier.query.count() == 46 assert RecordMetadata.query.count() == 15
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(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 grants(app, es, db, funders): """Grant records fixture.""" harvest_openaire_projects(source='tests/testdata/openaire_test.sqlite') 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 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_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
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()
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_grants_testdata(): """Load the grants test data.""" testdir = os.path.dirname(__file__) source = os.path.join(testdir, 'testdata/openaire_test.sqlite') harvest_openaire_projects(source=source)
def load_grants_testdata(): """Load the grants test data.""" testdir = os.path.dirname(__file__) source = os.path.join(testdir, 'testdata/openaire_test.sqlite') harvest_openaire_projects(path=source)