Permalink
Browse files

Make lint --conda_requirements check that an actual requirement is fo…

…und.

Add test cases .
  • Loading branch information...
jmchilton committed Feb 16, 2017
1 parent 8faf661 commit 6638caa07df74cd8b6c363e7dd82a715d271a317
@@ -10,6 +10,10 @@
def lint_requirements_in_conda(tool_source, lint_ctx):
"""Check requirements of tool source against best practice Conda channels."""
conda_targets = tool_source_conda_targets(tool_source)
if not conda_targets:
lint_ctx.warn("No valid package requirement tags found to check against Conda.")
return

for conda_target in conda_targets:
(best_hit, exact) = best_search_result(conda_target, channels_override=BEST_PRACTICE_CHANNELS)
conda_target_str = conda_target.package
@@ -0,0 +1,33 @@
<tool id="bwa" name="BWA" version="0.1.0">
<requirements>
<requirement type="package" version="0.4.12">bwa</requirement>
</requirements>
<stdio>
<exit_code range="2:" />
</stdio>
<command><![CDATA[
bwa > $output_1 2>&1
]]></command>
<inputs>
<param name="ignored" type="text" value="the default" />
</inputs>
<outputs>
<data name="output_1" format="txt" />
</outputs>
<tests>
<test>
<output name="output_1">
<assert_contents>
<has_text text="Version: 0.7.10" />
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
BWA is a mapper.
]]></help>
<citations>
<citation type="doi">10.1093/bioinformatics/btp324</citation>
<citation type="doi">10.1093/bioinformatics/btp698</citation>
</citations>
</tool>
@@ -0,0 +1,30 @@
<tool id="bwa" name="BWA" version="0.1.0">
<stdio>
<exit_code range="2:" />
</stdio>
<command><![CDATA[
bwa > $output_1 2>&1
]]></command>
<inputs>
<param name="ignored" type="text" value="the default" />
</inputs>
<outputs>
<data name="output_1" format="txt" />
</outputs>
<tests>
<test>
<output name="output_1">
<assert_contents>
<has_text text="Version: 0.7.10" />
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
BWA is a mapper.
]]></help>
<citations>
<citation type="doi">10.1093/bioinformatics/btp324</citation>
<citation type="doi">10.1093/bioinformatics/btp698</citation>
</citations>
</tool>
@@ -9,13 +9,11 @@
bwa > $output_1 2>&1
]]></command>
<inputs>
<param name="ignored" type="text" value="the default" />
</inputs>
<outputs>
<data name="output_1" />
<data name="output_1" format="txt" />
</outputs>
<help><![CDATA[
TODO: Fill in help.
]]></help>
<tests>
<test>
<output name="output_1">
@@ -25,4 +23,11 @@
</output>
</test>
</tests>
<help><![CDATA[
BWA is a mapper.
]]></help>
<citations>
<citation type="doi">10.1093/bioinformatics/btp324</citation>
<citation type="doi">10.1093/bioinformatics/btp698</citation>
</citations>
</tool>
@@ -69,3 +69,17 @@ def test_lint_doi(self):
fail_doi = os.path.join(TEST_TOOLS_DIR, "invalid_doi.xml")
lint_cmd = ["lint", "--doi", fail_doi]
self._check_exit_code(lint_cmd, exit_code=1)

def test_lint_conda_requirements_empty(self):
bwa_no_reqs = os.path.join(TEST_TOOLS_DIR, "bwa_without_requirements.xml")
lint_cmd = ["lint", bwa_no_reqs]
self._check_exit_code(lint_cmd)
lint_cmd = ["lint", "--conda_requirements", bwa_no_reqs]
self._check_exit_code(lint_cmd, exit_code=1)

def test_lint_conda_requirements_wrong_version(self):
bwa_wrong_version = os.path.join(TEST_TOOLS_DIR, "bwa_invalid_version.xml")
lint_cmd = ["lint", bwa_wrong_version]
self._check_exit_code(lint_cmd)
lint_cmd = ["lint", "--conda_requirements", bwa_wrong_version]
self._check_exit_code(lint_cmd, exit_code=1)

0 comments on commit 6638caa

Please sign in to comment.