def test_create_osf_export(path): ds = Dataset(path).create(force=True) ds.save() create_results = ds.create_sibling_osf( title="CI dl-create", # do not create a git-remote mode="exportonly") assert_result_count(create_results, 1, status='ok', type='dataset', name='osf-storage', path=ds.path) # if we got here, we created something at OSF; # make sure, we clean up afterwards try: # for now just run an export and make sure it doesn't fail ds.repo.call_git(['annex', 'export', 'HEAD', '--to', 'osf-storage']) finally: # clean remote end: cred = get_credentials(allow_interactive=False) osf = OSF(**cred) delete_node(osf.session, create_results[0]['id'])
def test_create_osf_simple(path): ds = Dataset(path).create(force=True) ds.save() file1 = Path('ds') / "file1.txt" create_results = ds.create_sibling_osf(name="osf") assert_result_count(create_results, 2, status='ok') assert_result_count(create_results, 1, status='ok', type='dataset', name="osf-storage", path=ds.path) assert_result_count(create_results, 1, status='ok', type='sibling', name="osf", path=ds.path) # if we got here, we created something at OSF; # make sure, we clean up afterwards try: # special remote is configured: remote_log = ds.repo.call_git( ['cat-file', 'blob', 'git-annex:remote.log']) assert_in("node={}".format(create_results[0]['id']), remote_log) # copy files over ds.repo.copy_to('.', "osf-storage") whereis = ds.repo.whereis(str(file1)) here = ds.config.get("annex.uuid") # files should be 'here' and on remote end: assert_equal(len(whereis), 2) assert_in(here, whereis) # drop content here ds.drop('.') whereis = ds.repo.whereis(str(file1)) # now on remote end only assert_equal(len(whereis), 1) assert_not_in(here, whereis) # and get content again from remote: ds.get('.') whereis = ds.repo.whereis(str(file1)) assert_equal(len(whereis), 2) assert_in(here, whereis) finally: # clean remote end: cred = get_credentials(allow_interactive=False) osf = OSF(**cred) delete_node(osf.session, create_results[0]['id'])