Exemplo n.º 1
0
def test_fill_data_library():
    """Test :func:`planemo.training.fill_data_library`."""
    train = Training(KWDS)
    train.kwds['tutorial_name'] = None
    train.kwds['slides'] = False
    train.kwds['hands_on'] = False
    train.init_training(CTX)
    train.kwds['tutorial_name'] = 'existing_tutorial'
    create_existing_tutorial('existing_tutorial', tuto_wo_zenodo_fp, train.topic)
    # no Zenodo link
    train.kwds['zenodo_link'] = None
    exp_exception = "A Zenodo link should be provided either in the metadata file or as argument of the command"
    with assert_raises_regexp(Exception, exp_exception):
        train.fill_data_library(CTX)
    # with a given Zenodo link and no Zenodo in metadata
    train.kwds['zenodo_link'] = zenodo_link
    train.fill_data_library(CTX)
    assert 'DOI: 10.5281/zenodo.1321885' in open(train.tuto.data_lib_fp, 'r').read()
    assert 'zenodo_link: %s' % zenodo_link in open(train.tuto.tuto_fp, 'r').read()
    # with a given Zenodo link and Zenodo in metadata
    new_z_link = 'https://zenodo.org/record/1324204'
    train.kwds['zenodo_link'] = new_z_link
    train.tuto = None
    train.fill_data_library(CTX)
    assert 'DOI: 10.5281/zenodo.1324204' in open(train.tuto.data_lib_fp, 'r').read()
    assert 'zenodo_link: %s' % new_z_link in open(train.tuto.tuto_fp, 'r').read()
    # with no given Zenodo link
    train.kwds['zenodo_link'] = None
    train.fill_data_library(CTX)
    assert 'DOI: 10.5281/zenodo.1324204' in open(train.tuto.data_lib_fp, 'r').read()
    assert 'zenodo_link: %s' % new_z_link in open(train.tuto.tuto_fp, 'r').read()
    # clean after
    shutil.rmtree(train.topics_dir)
    shutil.rmtree("metadata")
Exemplo n.º 2
0
def cli(ctx, uris, **kwds):
    """Build training template from workflow."""
    kwds["no_dependency_resolution"] = True
    training = Training(kwds)
    training.fill_data_library(ctx)