def test_topic_exists():
    """Test :func:`planemo.training.topic.Topic.exists`."""
    topic = Topic()
    assert not topic.exists()
    os.makedirs(topic.dir)
    assert topic.exists()
    shutil.rmtree(topic.parent_dir)
Exemple #2
0
def test_topic_exists():
    """Test :func:`planemo.training.topic.Topic.exists`."""
    topic = Topic()
    assert not topic.exists()
    os.makedirs(topic.dir)
    assert topic.exists()
    shutil.rmtree(topic.parent_dir)
def test_topic_create_topic_structure():
    """Test :func:`planemo.training.topic.Topic.create_topic_structure`."""
    topic = Topic()
    topic.create_topic_structure()
    topic_name = "new_topic"
    topic_title = "The new topic"
    # check the folder and its structure
    assert topic.exists()
    assert os.path.exists(topic.img_folder)
    assert os.path.exists(topic.tuto_folder)
    # create the index.md and the topic name
    assert os.path.exists(topic.index_fp)
    assert topic_name in open(topic.index_fp, 'r').read()
    # create the README.md and the topic name
    assert os.path.exists(topic.readme_fp)
    assert topic_title in open(topic.readme_fp, 'r').read()
    # check metadata content
    assert os.path.exists(topic.metadata_fp)
    metadata = load_yaml(topic.metadata_fp)
    assert metadata['name'] == topic_name
    # check dockerfile
    assert os.path.exists(topic.dockerfile_fp)
    assert topic_name in open(topic.dockerfile_fp, 'r').read()
    assert topic_title in open(topic.dockerfile_fp, 'r').read()
    # check introduction slide
    assert os.path.exists(topic.intro_slide_fp)
    assert topic_title in open(topic.intro_slide_fp, 'r').read()
    # check in metadata directory
    assert os.path.exists(os.path.join("metadata", "%s.yaml" % topic_name))
    # clean
    shutil.rmtree(topic.parent_dir)
    shutil.rmtree("metadata")
def test_topic_create_topic_structure():
    """Test :func:`planemo.training.topic.Topic.create_topic_structure`."""
    topic = Topic()
    topic.create_topic_structure()
    topic_name = "new_topic"
    topic_title = "The new topic"
    # check the folder and its structure
    assert topic.exists()
    assert os.path.exists(topic.img_folder)
    assert os.path.exists(topic.tuto_folder)
    # create the index.md and the topic name
    assert os.path.exists(topic.index_fp)
    assert topic_name in open(topic.index_fp, 'r').read()
    # create the README.md and the topic name
    assert os.path.exists(topic.readme_fp)
    assert topic_title in open(topic.readme_fp, 'r').read()
    # check metadata content
    assert os.path.exists(topic.metadata_fp)
    metadata = load_yaml(topic.metadata_fp)
    assert metadata['name'] == topic_name
    # check dockerfile
    assert os.path.exists(topic.dockerfile_fp)
    assert topic_name in open(topic.dockerfile_fp, 'r').read()
    assert topic_title in open(topic.dockerfile_fp, 'r').read()
    # check introduction slide
    assert os.path.exists(topic.intro_slide_fp)
    assert topic_title in open(topic.intro_slide_fp, 'r').read()
    # check in metadata directory
    assert os.path.exists(os.path.join("metadata", "%s.yaml" % topic_name))
    # clean
    shutil.rmtree(topic.parent_dir)
    shutil.rmtree("metadata")