-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into badge-for-jenkins
- Loading branch information
Showing
12 changed files
with
228 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from __future__ import absolute_import | ||
|
||
import mock | ||
|
||
from cwltool.main import main | ||
from .util import get_data | ||
|
||
def mocked_requests_head(*args): | ||
|
||
class MockResponse: | ||
def __init__(self, json_data, status_code, raise_for_status=None): | ||
self.json_data = json_data | ||
self.status_code = status_code | ||
self.raise_for_status = mock.Mock() | ||
self.raise_for_status.side_effect = raise_for_status | ||
|
||
def json(self): | ||
return self.json_data | ||
|
||
return MockResponse(None, 200) | ||
|
||
|
||
def mocked_requests_get(*args): | ||
|
||
class MockResponse: | ||
def __init__(self, json_data, status_code, raise_for_status=None): | ||
self.json_data = json_data | ||
self.text = json_data | ||
self.status_code = status_code | ||
self.raise_for_status = mock.Mock() | ||
self.raise_for_status.side_effect = raise_for_status | ||
|
||
def json(self): | ||
return self.json_data | ||
|
||
if args[0] == 'https://dockstore.org/api/api/ga4gh/v2/tools/quay.io%2Fbriandoconnor%2Fdockstore-tool-md5sum/versions/1.0.4/CWL/files': | ||
return MockResponse( | ||
[{"file_type": "CONTAINERFILE", "path": "Dockerfile"}, {"file_type": "PRIMARY_DESCRIPTOR", "path": "Dockstore.cwl"}, | ||
{"file_type": "TEST_FILE", "path": "test.json"}], 200) | ||
elif args[0] == 'https://dockstore.org/api/api/ga4gh/v2/tools/quay.io%2Fbriandoconnor%2Fdockstore-tool-md5sum/versions/1.0.4/plain-CWL/descriptor/Dockstore.cwl': | ||
string = open(get_data("tests/trs/Dockstore.cwl"), "r").read() | ||
return MockResponse(string, 200) | ||
elif args[0] == 'https://dockstore.org/api/api/ga4gh/v2/tools/%23workflow%2Fgithub.com%2Fdockstore-testing%2Fmd5sum-checker/versions/develop/plain-CWL/descriptor/md5sum-tool.cwl': | ||
string = open(get_data("tests/trs/md5sum-tool.cwl"), "r").read() | ||
return MockResponse(string, 200) | ||
elif args[0] == 'https://dockstore.org/api/api/ga4gh/v2/tools/%23workflow%2Fgithub.com%2Fdockstore-testing%2Fmd5sum-checker/versions/develop/plain-CWL/descriptor/md5sum-workflow.cwl': | ||
string = open(get_data("tests/trs/md5sum-workflow.cwl"), "r").read() | ||
return MockResponse(string, 200) | ||
elif args[ | ||
0] == 'https://dockstore.org/api/api/ga4gh/v2/tools/%23workflow%2Fgithub.com%2Fdockstore-testing%2Fmd5sum-checker/versions/develop/CWL/files': | ||
return MockResponse( | ||
[{"file_type": "TEST_FILE", "path": "md5sum-input-cwl.json"}, {"file_type": "SECONDARY_DESCRIPTOR", "path": "md5sum-tool.cwl"}, | ||
{"file_type": "PRIMARY_DESCRIPTOR", "path": "md5sum-workflow.cwl"}], 200) | ||
|
||
print ("A mocked call to TRS missed, target was %s", args[0]) | ||
return MockResponse(None, 404) | ||
|
||
|
||
@mock.patch('requests.Session.head', side_effect=mocked_requests_head) | ||
@mock.patch('requests.Session.get', side_effect=mocked_requests_get) | ||
def test_tool_trs_template(mock_head, mock_get): | ||
params = ["--make-template", r"quay.io/briandoconnor/dockstore-tool-md5sum:1.0.4"] | ||
return_value = main(params) | ||
mock_head.assert_called() | ||
mock_get.assert_called() | ||
assert return_value == 0 | ||
|
||
|
||
@mock.patch('requests.Session.head', side_effect=mocked_requests_head) | ||
@mock.patch('requests.Session.get', side_effect=mocked_requests_get) | ||
def test_workflow_trs_template(mock_head, mock_get): | ||
params = ["--make-template", r"#workflow/github.com/dockstore-testing/md5sum-checker:develop"] | ||
return_value = main(params) | ||
mock_head.assert_called() | ||
mock_get.assert_called() | ||
assert return_value == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env cwl-runner | ||
|
||
class: CommandLineTool | ||
id: Md5sum | ||
label: Simple md5sum tool | ||
cwlVersion: v1.0 | ||
|
||
$namespaces: | ||
dct: http://purl.org/dc/terms/ | ||
foaf: http://xmlns.com/foaf/0.1/ | ||
|
||
doc: | | ||
[![Docker Repository on Quay.io](https://quay.io/repository/briandoconnor/dockstore-tool-md5sum/status "Docker Repository on Quay.io")](https://quay.io/repository/briandoconnor/dockstore-tool-md5sum) | ||
[![Build Status](https://travis-ci.org/briandoconnor/dockstore-tool-md5sum.svg)](https://travis-ci.org/briandoconnor/dockstore-tool-md5sum) | ||
A very, very simple Docker container for the md5sum command. See the [README](https://github.com/briandoconnor/dockstore-tool-md5sum/blob/master/README.md) for more information. | ||
|
||
|
||
#dct:creator: | ||
# '@id': http://orcid.org/0000-0002-7681-6415 | ||
# foaf:name: Brian O'Connor | ||
# foaf:mbox: [email protected] | ||
|
||
requirements: | ||
- class: DockerRequirement | ||
dockerPull: quay.io/briandoconnor/dockstore-tool-md5sum:1.0.4 | ||
- class: InlineJavascriptRequirement | ||
|
||
hints: | ||
- class: ResourceRequirement | ||
# The command really requires very little resources. | ||
coresMin: 1 | ||
ramMin: 1024 | ||
outdirMin: 1024 | ||
|
||
inputs: | ||
input_file: | ||
type: File | ||
inputBinding: | ||
position: 1 | ||
doc: The file that will have its md5sum calculated. | ||
|
||
outputs: | ||
output_file: | ||
type: File | ||
format: http://edamontology.org/data_3671 | ||
outputBinding: | ||
glob: md5sum.txt | ||
doc: A text file that contains a single line that is the md5sum of the input file. | ||
|
||
baseCommand: [/bin/my_md5sum] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env cwl-runner | ||
|
||
class: CommandLineTool | ||
id: Md5sum | ||
label: Simple md5sum tool | ||
cwlVersion: v1.0 | ||
|
||
$namespaces: | ||
dct: http://purl.org/dc/terms/ | ||
foaf: http://xmlns.com/foaf/0.1/ | ||
|
||
requirements: | ||
- class: DockerRequirement | ||
dockerPull: quay.io/agduncan94/my-md5sum | ||
- class: InlineJavascriptRequirement | ||
|
||
hints: | ||
- class: ResourceRequirement | ||
# The command really requires very little resources. | ||
coresMin: 1 | ||
ramMin: 1024 | ||
outdirMin: 512 | ||
|
||
inputs: | ||
input_file: | ||
type: File | ||
inputBinding: | ||
position: 1 | ||
doc: The file that will have its md5sum calculated. | ||
|
||
outputs: | ||
output_file: | ||
type: File | ||
format: http://edamontology.org/data_3671 | ||
outputBinding: | ||
glob: md5sum.txt | ||
doc: A text file that contains a single line that is the md5sum of the input file. | ||
|
||
baseCommand: [/bin/my_md5sum] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cwlVersion: v1.0 | ||
class: Workflow | ||
|
||
inputs: | ||
input_file: File | ||
|
||
outputs: | ||
output_file: | ||
type: File | ||
outputSource: md5sum/output_file | ||
|
||
steps: | ||
md5sum: | ||
run: md5sum-tool.cwl | ||
in: | ||
input_file: input_file | ||
out: [output_file] |