Skip to content

Commit

Permalink
increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
giannisdoukas committed Jun 9, 2020
1 parent 41e7f65 commit 0193752
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
6 changes: 3 additions & 3 deletions cwlkernel/cwlrepository/cwlrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def register_tool(self, tool: WorkflowComponent) -> None:
path = Path(self._file_repository.write(f'{tool.id}.cwl', tool.to_yaml().encode()))
self._registry[tool.id] = (deepcopy(tool), path)

def register_tools(self, *args):
for tool in args:
self.register_tool(tool)
# def register_tools(self, *args):
# for tool in args:
# self.register_tool(tool)

def get_by_id(self, tool_id: str) -> Optional[WorkflowComponent]:
comp = self._registry.get(tool_id, None)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_CWLKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ def test_compose(self):
type: File
% newWorkflowAddStepIn tailstepid headstepid headoutput
tailinput: headstepid/headoutput
% newWorkflowAddOutputSource tailstepid/tailoutput File
% newWorkflowBuild""")
)

Expand All @@ -486,7 +487,7 @@ def test_compose(self):
"class": "Workflow",
"id": "main",
"inputs": [{'id': 'inputfile', 'type': 'File'}],
"outputs": [],
"outputs": [{'id': 'tailoutput', 'type': 'File', 'outputSource': "tailstepid/tailoutput"}],
"steps": {
"headstepid":
{
Expand All @@ -498,7 +499,7 @@ def test_compose(self):
{
"run": "tail.cwl",
"in": {"tailinput": "headstepid/headoutput"},
"out": []
"out": ['tailoutput']
},
},
'requirements': {}
Expand Down
31 changes: 28 additions & 3 deletions tests/test_cwlbuilder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import tempfile
import unittest
from pathlib import Path
from io import StringIO

import yaml
from io import StringIO

from cwlkernel.CWLBuilder import CWLSnippetBuilder

Expand Down Expand Up @@ -90,3 +88,30 @@ def test_snippet_builder(self):
yaml.load(StringIO(cwl_builder.get_current_code()), yaml.Loader),
yaml.load(StringIO(cwl_workflow.to_yaml()), yaml.Loader)
)

def test_build_without_id(self):
cwl_builder = CWLSnippetBuilder()
cwl_builder.append("""cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo
inputs:
- id: message
inputBinding:
position: 1
type: string
outputs: []""")
with self.assertRaises(ValueError):
cwl_builder.build()
cwl_builder.append("id: echo")
cwl_tool = cwl_builder.build()
self.assertDictEqual(
{'cwlVersion': 'v1.0',
'class': 'CommandLineTool',
'baseCommand': 'echo',
'id': 'echo',
'inputs': [{'id': 'message',
'inputBinding': {'position': 1},
'type': 'string'}],
'outputs': []},
cwl_tool.to_dict()
)

0 comments on commit 0193752

Please sign in to comment.