def dumpgrants(destination, as_json=None, setspec=None): """Harvest grants from OpenAIRE and store them locally.""" if os.path.isfile(destination): click.confirm("Database '{0}' already exists." "Do you want to write to it?".format(destination), abort=True) # no cover dumper = OAIREDumper(destination, setspec=setspec) dumper.dump(as_json=as_json)
def test_oaire_dumper(db, sqlite_tmpdb): recuuid = uuid.uuid4() PersistentIdentifier.create( 'frdoi', '10.13039/501100000925', object_type='rec', object_uuid=recuuid, status='R') Record.create({'acronyms': ['EC']}, id_=recuuid) dumper = OAIREDumper(destination=sqlite_tmpdb) # We expect to harvest 5 record from the MockSickle. # with 'commit_batch_size=2', we will make 3 commits to sqlite db dumper.dump(commit_batch_size=2) loader = LocalOAIRELoader(source=sqlite_tmpdb) records = list(loader.iter_grants()) assert len(records) == 5
def test_oaire_dumper(db, sqlite_tmpdb): """Test the grants dumper to local destination.""" recuuid = uuid.uuid4() PersistentIdentifier.create( 'frdoi', '10.13039/501100000925', object_type='rec', object_uuid=recuuid, status='R') Record.create({'acronyms': ['EC']}, id_=recuuid) dumper = OAIREDumper(destination=sqlite_tmpdb) # We expect to harvest 5 record from the MockSickle. # with 'commit_batch_size=2', we will make 3 commits to sqlite db dumper.dump(commit_batch_size=2) loader = LocalOAIRELoader(source=sqlite_tmpdb) records = list(loader.iter_grants()) assert len(records) == 5