Skip to content

Commit 24f40b5

Browse files
committed
add some basic tests
1 parent a8bfe51 commit 24f40b5

File tree

10 files changed

+107
-0
lines changed

10 files changed

+107
-0
lines changed
File renamed without changes.
File renamed without changes.

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@
1515
'schema_salad',
1616
'typing_extensions',
1717
],
18+
setup_requires=['pytest-runner'],
19+
tests_require=['pytest'],
20+
test_suite='tests',
1821
)

testdata/dockstore-tool-md5sum.cwl

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
class: CommandLineTool
4+
id: Md5sum
5+
label: Simple md5sum tool
6+
cwlVersion: v1.0
7+
8+
$namespaces:
9+
dct: http://purl.org/dc/terms/
10+
foaf: http://xmlns.com/foaf/0.1/
11+
12+
doc: |
13+
[![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)
14+
[![Build Status](https://travis-ci.org/briandoconnor/dockstore-tool-md5sum.svg)](https://travis-ci.org/briandoconnor/dockstore-tool-md5sum)
15+
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.
16+
17+
18+
#dct:creator:
19+
# '@id': http://orcid.org/0000-0002-7681-6415
20+
# foaf:name: Brian O'Connor
21+
# foaf:mbox: [email protected]
22+
23+
requirements:
24+
- class: DockerRequirement
25+
dockerPull: quay.io/briandoconnor/dockstore-tool-md5sum:1.0.4
26+
- class: InlineJavascriptRequirement
27+
28+
hints:
29+
- class: ResourceRequirement
30+
# The command really requires very little resources.
31+
coresMin: 1
32+
ramMin: 1024
33+
outdirMin: 512
34+
35+
inputs:
36+
input_file:
37+
type: File
38+
inputBinding:
39+
position: 1
40+
doc: The file that will have its md5sum calculated.
41+
42+
outputs:
43+
output_file:
44+
type: File
45+
format: http://edamontology.org/data_3671
46+
outputBinding:
47+
glob: md5sum.txt
48+
doc: A text file that contains a single line that is the md5sum of the input file.
49+
50+
baseCommand: [/bin/my_md5sum]
51+

testdata/md5sum.cwl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cwlVersion: v1.0
2+
class: Workflow
3+
4+
inputs:
5+
input_file: File
6+
7+
outputs:
8+
output_file:
9+
type: File
10+
outputSource: md5sum/output_file
11+
12+
steps:
13+
md5sum:
14+
run: dockstore-tool-md5sum.cwl
15+
in:
16+
input_file: input_file
17+
out: [output_file]
18+

testdata/md5sum.input

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

testdata/md5sum.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"output_file": {"path": "/tmp/md5sum.txt", "class": "File"},
2+
"input_file": {"path": "md5sum.input", "class": "File"}}

tests/__init__.py

Whitespace-only changes.

tests/test_cite_extract.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from unittest import TestCase
2+
from pathlib import Path
3+
from cwl_utils.cite_extract import traverse_workflow
4+
import cwl_utils.parser_v1_0 as parser
5+
6+
HERE = Path(__file__).resolve().parent
7+
TEST_CWL = HERE / "../testdata/md5sum.cwl"
8+
9+
10+
class TestCiteExtract(TestCase):
11+
def test_traverse_workflow(self):
12+
loaded = parser.load_document(str(TEST_CWL.resolve()))
13+
traverse_workflow(loaded)

tests/test_docker_extract.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from unittest import TestCase
2+
from pathlib import Path
3+
from tempfile import TemporaryDirectory
4+
from cwl_utils.docker_extract import traverse, get_image_name, save_docker_image, load_docker_image
5+
import cwl_utils.parser_v1_0 as parser
6+
7+
HERE = Path(__file__).resolve().parent
8+
TEST_CWL = HERE / "../testdata/md5sum.cwl"
9+
10+
11+
class TestDockerExtract(TestCase):
12+
def test_traverse_workflow(self):
13+
loaded = parser.load_document(str(TEST_CWL.resolve()))
14+
15+
with TemporaryDirectory() as tmpdir:
16+
for req in set(traverse(loaded)):
17+
image_name = get_image_name(req)
18+
save_docker_image(req, image_name, tmpdir)
19+
_ = load_docker_image(image_name)

0 commit comments

Comments
 (0)