Example #1
0
 def test_validate_subtool_metadata(self):
     validate_subtool_metadata = metadata_validator_factory(SubtoolMetadata)
     metadata_path = get_tool_metadata('STAR',
                                       '2.5',
                                       subtool_name='alignReads')
     validate_subtool_metadata(metadata_path)
     return
Example #2
0
 def test_handle_duplicate_subtool_identifier_2(self):
     """
     Add two subtools and parent with one command.
     :return:
     """
     tool_name = 'samtools'
     tool_version = '1.x'
     subtool_name = 'dict'  # both subtool identifiers start with 'bb'
     subtool_name_2 = 'faidx'
     with TemporaryDirectory() as temp_dir:
         self.make_empty_tools_index(temp_dir)
         add_tool(tool_name, tool_version, [subtool_name, subtool_name_2], root_repo_path=temp_dir, refresh_index=False)
         subtool_1_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name, base_dir=temp_dir)
         subtool_2_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name_2, base_dir=temp_dir)
         subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path)
         subtool_2_metadata = SubtoolMetadata.load_from_file(subtool_2_metadata_path)
     self.assertNotEqual(subtool_1_metadata.identifier, subtool_2_metadata.identifier)
     return
Example #3
0
 def test_validate_parent_tool_metadata_fail(self):
     validate_parent_metadata = metadata_validator_factory(
         ParentToolMetadata)
     metadata_path = get_tool_metadata('cat',
                                       '8.x',
                                       parent=True,
                                       base_dir=self.invalid_content_dir)
     with self.assertRaises(AttributeError):
         validate_parent_metadata(metadata_path)
     return
 def test_make_file(self):
     p_metadata = ParentToolMetadata(name=TestMakeParentToolMetadata.test_dict['name'], softwareVersion=test_constants['test_software_version'])
     with TemporaryDirectory(prefix='xD_test1', suffix='') as tmpdir:
         parent_metadata_path = get_tool_metadata(TestMakeParentToolMetadata.test_dict['name'], test_constants['test_software_version']['versionName'], parent=True, base_dir=tmpdir)
         if not parent_metadata_path.exists():
             parent_metadata_path.parent.mkdir(parents=True)
         p_metadata.mk_file(base_dir=tmpdir, replace_none=True)
         with parent_metadata_path.open('r') as file:
             test_file_dict = safe_load(file)
     self.assertEqual(test_file_dict['name'], TestMakeParentToolMetadata.test_dict['name'])
Example #5
0
 def test_validate_subtool_metadata_fail(self):
     validate_subtool_metadata = metadata_validator_factory(SubtoolMetadata)
     # metadata_path = Path.cwd() / 'tests/test_files/test_content/invalid_content/cwl-tools/samtools/1.9/samtools_view/samtools-view-metadata.yaml' # Works for now.  # subtool name not in parent featurelist.
     metadata_path = get_tool_metadata('samtools',
                                       '1.x',
                                       subtool_name='view',
                                       base_dir=self.invalid_content_dir)
     assert metadata_path.exists()
     with self.assertRaises(ValueError):
         validate_subtool_metadata(metadata_path)
     return
Example #6
0
    def test_handle_duplicate_subtool_identifier(self):
        """
        Add subtools one at a time.
        :return:
        """
        tool_name = 'samtools'
        tool_version = '1.x'
        subtool_name = 'dict'  # both subtool identifiers start with 'bb'
        subtool_name_2 = 'faidx'
        with TemporaryDirectory() as temp_dir:
            self.make_empty_tools_index(temp_dir)
            add_tool(tool_name, tool_version, subtool_name, root_repo_path=temp_dir, refresh_index=False)
            add_subtool(tool_name, tool_version, subtool_name_2, root_repo_path=temp_dir, update_featureList=True)
            subtool_1_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name, base_dir=temp_dir)
            subtool_2_metadata_path = get_tool_metadata(tool_name, tool_version, subtool_name_2, base_dir=temp_dir)
            with self.assertRaises(InIndexError):
                subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path, _in_index=False, root_repo_path=temp_dir)
            subtool_1_metadata = SubtoolMetadata.load_from_file(subtool_1_metadata_path, _in_index=True, root_repo_path=temp_dir)
            subtool_2_metadata = SubtoolMetadata.load_from_file(subtool_2_metadata_path, _in_index=True,
                                                            root_repo_path=temp_dir)
        self.assertNotEqual(subtool_1_metadata.identifier, subtool_2_metadata.identifier)

        return
Example #7
0
 def test_add_parent_only(self):
     with TemporaryDirectory(prefix='dont_see me_') as tmp_dir:
         self.make_empty_tools_index(tmp_dir)
         tool_name = 'test__1'
         tool_version = '123'
         add_tool(tool_name, tool_version, root_repo_path=tmp_dir, refresh_index=False)  # Index is not refreshed because there is nothing in the content repo. Will throw FileNotFound error when trying to traverse directories.
         # the tool added should be the only identifier in the index.
         parent_metadata_path = get_tool_metadata(tool_name, tool_version, parent=True, base_dir=tmp_dir)
         with self.assertRaises(InIndexError):  # This should fail because trying to assign identifier that is already uses (by itself).
             parent_metadata = ParentToolMetadata.load_from_file(parent_metadata_path, _in_index=False,
                                                                 root_repo_path=tmp_dir)
             assert True
         parent_metadata = ParentToolMetadata.load_from_file(parent_metadata_path, root_repo_path=tmp_dir) # this should succeed with the _in_index flag.
         assert True
     return
Example #8
0
 def test_make_file(self):
     parent_tool_name = 'parentName'
     subtool_name = 'subtoolName'
     tool_version = 'test_version'
     with TemporaryDirectory(prefix='tool_instance_metadata') as tmpdir:
         self.make_empty_tools_dir(tmpdir)
         add_content([
             '-p', tmpdir, 'tool', parent_tool_name, tool_version,
             subtool_name
         ])
         subtool_path = get_tool_metadata(parent_tool_name,
                                          tool_version,
                                          subtool_name,
                                          base_dir=tmpdir)
         subtool_metadata = SubtoolMetadata.load_from_file(subtool_path)
         subtool_instance = subtool_metadata.mk_instance()
         subtool_instance.mk_file(base_dir=tmpdir)
     return
 def test_make_file(self):
     with TemporaryDirectory(prefix='xD_test1', suffix='') as tmpdir:
         p_metadata = ParentToolMetadata(
             name=TestMakeParentToolMetadata.test_dict['name'],
             softwareVersion=test_constants['test_software_version'],
             check_index=False,
             root_repo_path=tmpdir)
         self.make_empty_tools_index(tmpdir)
         parent_metadata_path = get_tool_metadata(
             TestMakeParentToolMetadata.test_dict['name'],
             test_constants['test_software_version']['versionName'],
             parent=True,
             base_dir=tmpdir)
         if not parent_metadata_path.exists():
             parent_metadata_path.parent.mkdir(parents=True)
         p_metadata.mk_file(
             base_dir=tmpdir, replace_none=True, update_index=True
         )  # Don't try to update an index file. There isn't one.
         with parent_metadata_path.open('r') as file:
             test_file_dict = safe_load(file)
     self.assertEqual(test_file_dict['name'],
                      TestMakeParentToolMetadata.test_dict['name'])
Example #10
0
 def test_validate_parent_tool_metadata(self):
     validate_parent_metadata = metadata_validator_factory(
         ParentToolMetadata)
     metadata_path = get_tool_metadata('STAR', '2.5', parent=True)
     validate_parent_metadata(metadata_path)