Skip to content

Commit

Permalink
add some basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gijzelaerr committed Jan 23, 2019
1 parent a8bfe51 commit 24f40b5
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
'schema_salad',
'typing_extensions',
],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
test_suite='tests',
)
51 changes: 51 additions & 0 deletions testdata/dockstore-tool-md5sum.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/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: briandoconnor@gmail.com

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: 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]

18 changes: 18 additions & 0 deletions testdata/md5sum.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cwlVersion: v1.0
class: Workflow

inputs:
input_file: File

outputs:
output_file:
type: File
outputSource: md5sum/output_file

steps:
md5sum:
run: dockstore-tool-md5sum.cwl
in:
input_file: input_file
out: [output_file]

1 change: 1 addition & 0 deletions testdata/md5sum.input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
2 changes: 2 additions & 0 deletions testdata/md5sum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"output_file": {"path": "/tmp/md5sum.txt", "class": "File"},
"input_file": {"path": "md5sum.input", "class": "File"}}
Empty file added tests/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tests/test_cite_extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from unittest import TestCase
from pathlib import Path
from cwl_utils.cite_extract import traverse_workflow
import cwl_utils.parser_v1_0 as parser

HERE = Path(__file__).resolve().parent
TEST_CWL = HERE / "../testdata/md5sum.cwl"


class TestCiteExtract(TestCase):
def test_traverse_workflow(self):
loaded = parser.load_document(str(TEST_CWL.resolve()))
traverse_workflow(loaded)
19 changes: 19 additions & 0 deletions tests/test_docker_extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from unittest import TestCase
from pathlib import Path
from tempfile import TemporaryDirectory
from cwl_utils.docker_extract import traverse, get_image_name, save_docker_image, load_docker_image
import cwl_utils.parser_v1_0 as parser

HERE = Path(__file__).resolve().parent
TEST_CWL = HERE / "../testdata/md5sum.cwl"


class TestDockerExtract(TestCase):
def test_traverse_workflow(self):
loaded = parser.load_document(str(TEST_CWL.resolve()))

with TemporaryDirectory() as tmpdir:
for req in set(traverse(loaded)):
image_name = get_image_name(req)
save_docker_image(req, image_name, tmpdir)
_ = load_docker_image(image_name)

0 comments on commit 24f40b5

Please sign in to comment.