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_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_init_from_metadata(): """Test :func:`planemo.training.topic.Topic.init_from_metadata`.""" topic = Topic() os.makedirs(topic.dir) shutil.copy(os.path.join(TEST_DATA_DIR, 'training_metadata.yaml'), topic.metadata_fp) topic.init_from_metadata() assert topic.name == 'test' assert topic.title == 'Test' assert topic.summary == 'Summary' assert topic.requirements[0].title == 'Galaxy introduction' assert 'maintainer1' in topic.maintainers shutil.rmtree(topic.parent_dir)
def test_topic_export_metadata_to_ordered_dict(): """Test :func:`planemo.training.topic.Topic.export_metadata_to_ordered_dict`.""" topic = Topic() metadata = topic.export_metadata_to_ordered_dict() assert 'name' in metadata assert metadata['name'] == "new_topic" assert 'type' in metadata assert 'title' in metadata assert 'summary' in metadata assert 'requirements' in metadata assert 'docker_image' in metadata assert 'maintainers' in metadata
def test_topic_export_metadata_to_ordered_dict(): """Test :func:`planemo.training.topic.Topic.export_metadata_to_ordered_dict`.""" topic = Topic() metadata = topic.export_metadata_to_ordered_dict() assert 'name' in metadata assert metadata['name'] == "new_topic" assert 'type' in metadata assert 'title' in metadata assert 'summary' in metadata assert 'requirements' in metadata assert 'docker_image' in metadata assert 'maintainers' in metadata assert 'references' in metadata
def test_topic_init_from_metadata(): """Test :func:`planemo.training.topic.Topic.init_from_metadata`.""" topic = Topic() os.makedirs(topic.dir) shutil.copy(os.path.join(TEST_DATA_DIR, 'training_metadata.yaml'), topic.metadata_fp) topic.init_from_metadata() assert topic.name == 'test' assert topic.title == 'Test' assert topic.summary == 'Summary' assert topic.requirements[0].topic_name == 'introduction' assert topic.requirements[0].tutorials == ['peaks2genes'] assert 'maintainer1' in topic.maintainers shutil.rmtree(topic.parent_dir)
def test_topic_set_paths(): """Test :func:`planemo.training.topic.Topic.set_paths`.""" new_name = 'the_new_name' topic = Topic() topic.name = new_name topic.set_paths() assert new_name in topic.dir assert new_name in topic.img_folder assert new_name in topic.tuto_folder assert new_name in topic.index_fp assert new_name in topic.readme_fp assert new_name in topic.metadata_fp assert new_name in topic.docker_folder assert new_name in topic.dockerfile_fp assert new_name in topic.slides_folder
def test_topic_init_from_kwds(): """Test :func:`planemo.training.topic.Topic.init_from_kwds`.""" topic = Topic() topic.init_from_kwds({ 'topic_name': "topic", 'topic_title': "New topic", 'topic_target': "admin", 'topic_summary': "Topic summary" }) assert topic.name == "topic" assert topic.type == "admin" assert topic.title == "New topic" assert topic.summary == "Topic summary" assert topic.dir == "topics/topic" assert len(topic.requirements) == 0
def test_topic_init_from_kwds(): """Test :func:`planemo.training.topic.Topic.init_from_kwds`.""" topic = Topic() topic.init_from_kwds({ 'topic_name': "topic", 'topic_title': "New topic", 'topic_target': "admin", 'topic_summary': "Topic summary" }) assert topic.name == "topic" assert topic.type == "admin" assert topic.title == "New topic" assert topic.summary == "Topic summary" assert topic.dir == "topics/topic" assert len(topic.requirements) == 0 assert len(topic.references) == 0
def test_topic_get_references(): """Test :func:`planemo.training.topic.Topic.get_references`.""" topic = Topic() refs = topic.get_references() assert len(refs) == 1 assert 'authors' in refs[0]
def test_topic_get_requirements(): """Test :func:`planemo.training.topic.Topic.get_requirements`.""" topic = Topic() reqs = topic.get_requirements() assert len(reqs) == 1 assert 'title' in reqs[0]
def test_topic_get_requirements(): """Test :func:`planemo.training.topic.Topic.get_requirements`.""" topic = Topic() reqs = topic.get_requirements() assert len(reqs) == 1 assert 'topic_name' in reqs[0]