3 new commits in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/682bc706f5d6/
Changeset: 682bc706f5d6
User: jmchilton
Date: 2013-06-24 16:28:14
Summary: Create unit test directory with example test. Enable coverage report
generation of unit tests (run_unit_tests.sh will automatically add --with-coverage to
nosetests call if coverage is on the path, coverage report can than be generated with
'coverage html' and viewed at htmlcov/index.html). Update .hgignore to reflect
these changes.
Affected #: 6 files
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 .coveragerc
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,3 @@
+[run]
+branch = True
+include = lib/galaxy/*
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -82,6 +82,9 @@
# Test output
run_functional_tests.html
test/tool_shed/tmp/*
+.coverage
+htmlcov
+run_unit_tests.html
# Project files
*.kpf
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 lib/galaxy/tools/loader.py
--- a/lib/galaxy/tools/loader.py
+++ b/lib/galaxy/tools/loader.py
@@ -202,199 +202,3 @@
current_index += 1
parent_el.insert(current_index, deepcopy(target))
parent_el.remove(query)
-
-
-def test_loader():
- """
- Function to test this module. Galaxy doesn't seem to have a
- place to put unit tests that are not doctests. These tests can
- be run with nosetests via the following command:
-
- % nosetests lib/galaxy/tools/loader.py
-
- """
- from tempfile import mkdtemp
- from shutil import rmtree
-
- class TestToolDirectory(object):
- def __init__(self):
- self.temp_directory = mkdtemp()
-
- def __enter__(self):
- return self
-
- def __exit__(self, type, value, tb):
- rmtree(self.temp_directory)
-
- def write(self, contents, name="tool.xml"):
- open(os.path.join(self.temp_directory, name), "w").write(contents)
-
- def load(self, name="tool.xml", preprocess=True):
- if preprocess:
- loader = load_tool
- else:
- loader = parse_xml
- return loader(os.path.join(self.temp_directory, name))
-
- ## Test simple macro replacement.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <macro name="inputs">
- <inputs />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load(preprocess=False)
- assert xml.find("inputs") is None
- xml = tool_dir.load(preprocess=True)
- assert xml.find("inputs") is not None
-
- # Test importing macros from external files
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <import>external.xml</import>
- </macros>
-</tool>''')
-
- tool_dir.write('''
-<macros>
- <macro name="inputs">
- <inputs />
- </macro>
-</macros>''', name="external.xml")
- xml = tool_dir.load(preprocess=False)
- assert xml.find("inputs") is None
- xml = tool_dir.load(preprocess=True)
- assert xml.find("inputs") is not None
-
- # Test macros with unnamed yield statements.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert xml.find("inputs").find("input").get("name")
== "first_input"
-
- # Test recursive macro applications.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- <expand macro="second" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- <macro name="second">
- <input name="second_input" />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
-
- # Test recursive macro applications.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- <expand macro="second" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- <macro name="second">
- <expand macro="second_delegate" />
- </macro>
- <macro name="second_delegate">
- <input name="second_input" />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
-
- # Test <xml> is shortcut for macro type="xml"
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <xml name="inputs">
- <inputs />
- </xml>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert xml.find("inputs") is not None
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <command interpreter="python">tool_wrapper.py
- #include source=$tool_params
- </command>
- <macros>
- <template name="tool_params">-a 1 -b 2</template>
- </macros>
-</tool>
-''')
- xml = tool_dir.load()
- params_dict = template_macro_params(xml.getroot())
- assert params_dict['tool_params'] == "-a 1 -b 2"
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <macros>
- <token name="@CITATION@">The citation.</token>
- </macros>
- <help>@CITATION@</help>
- <another>
- <tag />
- </another>
-</tool>
-''')
- xml = tool_dir.load()
- help_el = xml.find("help")
- assert help_el.text == "The citation.", help_el.text
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <macros>
- <token name="@TAG_VAL@">The value.</token>
- </macros>
- <another>
- <tag value="@TAG_VAL@" />
- </another>
-</tool>
-''')
- xml = tool_dir.load()
- tag_el = xml.find("another").find("tag")
- value = tag_el.get('value')
- assert value == "The value.", value
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 run_unit_tests.sh
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -3,7 +3,14 @@
## Excluding controllers due to the problematic genetrack dependency
## Excluding job runners due to various external dependencies
-python ./scripts/nosetests.py -v -w lib \
+COVERAGE=`which coverage`
+COVERAGE_ARG=""
+if [ $COVERAGE ]; then
+ COVERAGE_ARG="--with-coverage"
+fi
+
+python ./scripts/nosetests.py -v \
+ $COVERAGE_ARG \
--with-nosehtml --html-report-file run_unit_tests.html \
--with-doctest --exclude=functional --exclude="^get" \
- --exclude=controllers --exclude=runners
+ --exclude=controllers --exclude=runners lib test/unit
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 test/TESTING.md
--- /dev/null
+++ b/test/TESTING.md
@@ -0,0 +1,7 @@
+Galaxy Testing
+==============
+
+The Galaxy code base is large and contains many kinds of tests. Please
+consult the [Galaxy
+wiki](http://wiki.galaxyproject.org/Admin/Running%20Tests) for more
+information on testing Galaxy.
diff -r dc6e0347edffb96fe4e633b362ad21a9f5a83e81 -r
682bc706f5d6c8caab7a46e405cdee158268c373 test/unit/test_tool_loader.py
--- /dev/null
+++ b/test/unit/test_tool_loader.py
@@ -0,0 +1,191 @@
+from tempfile import mkdtemp
+from shutil import rmtree
+import os
+
+from galaxy.util import parse_xml
+from galaxy.tools.loader import template_macro_params, load_tool
+
+def test_loader():
+
+ class TestToolDirectory(object):
+ def __init__(self):
+ self.temp_directory = mkdtemp()
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, tb):
+ rmtree(self.temp_directory)
+
+ def write(self, contents, name="tool.xml"):
+ open(os.path.join(self.temp_directory, name), "w").write(contents)
+
+ def load(self, name="tool.xml", preprocess=True):
+ if preprocess:
+ loader = load_tool
+ else:
+ loader = parse_xml
+ return loader(os.path.join(self.temp_directory, name))
+
+ ## Test simple macro replacement.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <macro name="inputs">
+ <inputs />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load(preprocess=False)
+ assert xml.find("inputs") is None
+ xml = tool_dir.load(preprocess=True)
+ assert xml.find("inputs") is not None
+
+ # Test importing macros from external files
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <import>external.xml</import>
+ </macros>
+</tool>''')
+
+ tool_dir.write('''
+<macros>
+ <macro name="inputs">
+ <inputs />
+ </macro>
+</macros>''', name="external.xml")
+ xml = tool_dir.load(preprocess=False)
+ assert xml.find("inputs") is None
+ xml = tool_dir.load(preprocess=True)
+ assert xml.find("inputs") is not None
+
+ # Test macros with unnamed yield statements.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert xml.find("inputs").find("input").get("name")
== "first_input"
+
+ # Test recursive macro applications.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ <expand macro="second" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ <macro name="second">
+ <input name="second_input" />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
+
+ # Test recursive macro applications.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ <expand macro="second" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ <macro name="second">
+ <expand macro="second_delegate" />
+ </macro>
+ <macro name="second_delegate">
+ <input name="second_input" />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
+
+ # Test <xml> is shortcut for macro type="xml"
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <xml name="inputs">
+ <inputs />
+ </xml>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert xml.find("inputs") is not None
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <command interpreter="python">tool_wrapper.py
+ #include source=$tool_params
+ </command>
+ <macros>
+ <template name="tool_params">-a 1 -b 2</template>
+ </macros>
+</tool>
+''')
+ xml = tool_dir.load()
+ params_dict = template_macro_params(xml.getroot())
+ assert params_dict['tool_params'] == "-a 1 -b 2"
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <macros>
+ <token name="@CITATION@">The citation.</token>
+ </macros>
+ <help>@CITATION@</help>
+ <another>
+ <tag />
+ </another>
+</tool>
+''')
+ xml = tool_dir.load()
+ help_el = xml.find("help")
+ assert help_el.text == "The citation.", help_el.text
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <macros>
+ <token name="@TAG_VAL@">The value.</token>
+ </macros>
+ <another>
+ <tag value="@TAG_VAL@" />
+ </another>
+</tool>
+''')
+ xml = tool_dir.load()
+ tag_el = xml.find("another").find("tag")
+ value = tag_el.get('value')
+ assert value == "The value.", value
https://bitbucket.org/galaxy/galaxy-central/commits/71bd004a3354/
Changeset: 71bd004a3354
User: jmchilton
Date: 2013-06-24 16:29:46
Summary: Update README.txt to reflect Python 2.5 is no longer supported.
Affected #: 1 file
diff -r 682bc706f5d6c8caab7a46e405cdee158268c373 -r
71bd004a3354b7132db03cb17b6a45997677e100 README.txt
--- a/README.txt
+++ b/README.txt
@@ -7,7 +7,7 @@
HOW TO START
============
-Galaxy requires Python 2.5, 2.6 or 2.7. To check your python version, run:
+Galaxy requires Python 2.6 or 2.7. To check your python version, run:
% python -V
Python 2.7.3
https://bitbucket.org/galaxy/galaxy-central/commits/6673bd3bf457/
Changeset: 6673bd3bf457
User: dannon
Date: 2013-07-01 11:53:46
Summary: Merged in jmchilton/galaxy-central-multi-input-tool-fixes-2 (pull request
#189)
Small Unit Testing Improvements
Affected #: 7 files
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 .coveragerc
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,3 @@
+[run]
+branch = True
+include = lib/galaxy/*
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 .hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -82,6 +82,9 @@
# Test output
run_functional_tests.html
test/tool_shed/tmp/*
+.coverage
+htmlcov
+run_unit_tests.html
# Project files
*.kpf
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 README.txt
--- a/README.txt
+++ b/README.txt
@@ -7,7 +7,7 @@
HOW TO START
============
-Galaxy requires Python 2.5, 2.6 or 2.7. To check your python version, run:
+Galaxy requires Python 2.6 or 2.7. To check your python version, run:
% python -V
Python 2.7.3
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 lib/galaxy/tools/loader.py
--- a/lib/galaxy/tools/loader.py
+++ b/lib/galaxy/tools/loader.py
@@ -202,199 +202,3 @@
current_index += 1
parent_el.insert(current_index, deepcopy(target))
parent_el.remove(query)
-
-
-def test_loader():
- """
- Function to test this module. Galaxy doesn't seem to have a
- place to put unit tests that are not doctests. These tests can
- be run with nosetests via the following command:
-
- % nosetests lib/galaxy/tools/loader.py
-
- """
- from tempfile import mkdtemp
- from shutil import rmtree
-
- class TestToolDirectory(object):
- def __init__(self):
- self.temp_directory = mkdtemp()
-
- def __enter__(self):
- return self
-
- def __exit__(self, type, value, tb):
- rmtree(self.temp_directory)
-
- def write(self, contents, name="tool.xml"):
- open(os.path.join(self.temp_directory, name), "w").write(contents)
-
- def load(self, name="tool.xml", preprocess=True):
- if preprocess:
- loader = load_tool
- else:
- loader = parse_xml
- return loader(os.path.join(self.temp_directory, name))
-
- ## Test simple macro replacement.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <macro name="inputs">
- <inputs />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load(preprocess=False)
- assert xml.find("inputs") is None
- xml = tool_dir.load(preprocess=True)
- assert xml.find("inputs") is not None
-
- # Test importing macros from external files
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <import>external.xml</import>
- </macros>
-</tool>''')
-
- tool_dir.write('''
-<macros>
- <macro name="inputs">
- <inputs />
- </macro>
-</macros>''', name="external.xml")
- xml = tool_dir.load(preprocess=False)
- assert xml.find("inputs") is None
- xml = tool_dir.load(preprocess=True)
- assert xml.find("inputs") is not None
-
- # Test macros with unnamed yield statements.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert xml.find("inputs").find("input").get("name")
== "first_input"
-
- # Test recursive macro applications.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- <expand macro="second" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- <macro name="second">
- <input name="second_input" />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
-
- # Test recursive macro applications.
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs">
- <input name="first_input" />
- <expand macro="second" />
- </expand>
- <macros>
- <macro name="inputs">
- <inputs>
- <yield />
- </inputs>
- </macro>
- <macro name="second">
- <expand macro="second_delegate" />
- </macro>
- <macro name="second_delegate">
- <input name="second_input" />
- </macro>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
-
- # Test <xml> is shortcut for macro type="xml"
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <expand macro="inputs" />
- <macros>
- <xml name="inputs">
- <inputs />
- </xml>
- </macros>
-</tool>''')
- xml = tool_dir.load()
- assert xml.find("inputs") is not None
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <command interpreter="python">tool_wrapper.py
- #include source=$tool_params
- </command>
- <macros>
- <template name="tool_params">-a 1 -b 2</template>
- </macros>
-</tool>
-''')
- xml = tool_dir.load()
- params_dict = template_macro_params(xml.getroot())
- assert params_dict['tool_params'] == "-a 1 -b 2"
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <macros>
- <token name="@CITATION@">The citation.</token>
- </macros>
- <help>@CITATION@</help>
- <another>
- <tag />
- </another>
-</tool>
-''')
- xml = tool_dir.load()
- help_el = xml.find("help")
- assert help_el.text == "The citation.", help_el.text
-
- with TestToolDirectory() as tool_dir:
- tool_dir.write('''
-<tool>
- <macros>
- <token name="@TAG_VAL@">The value.</token>
- </macros>
- <another>
- <tag value="@TAG_VAL@" />
- </another>
-</tool>
-''')
- xml = tool_dir.load()
- tag_el = xml.find("another").find("tag")
- value = tag_el.get('value')
- assert value == "The value.", value
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 run_unit_tests.sh
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -3,7 +3,14 @@
## Excluding controllers due to the problematic genetrack dependency
## Excluding job runners due to various external dependencies
-python ./scripts/nosetests.py -v -w lib \
+COVERAGE=`which coverage`
+COVERAGE_ARG=""
+if [ $COVERAGE ]; then
+ COVERAGE_ARG="--with-coverage"
+fi
+
+python ./scripts/nosetests.py -v \
+ $COVERAGE_ARG \
--with-nosehtml --html-report-file run_unit_tests.html \
--with-doctest --exclude=functional --exclude="^get" \
- --exclude=controllers --exclude=runners
+ --exclude=controllers --exclude=runners lib test/unit
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 test/TESTING.md
--- /dev/null
+++ b/test/TESTING.md
@@ -0,0 +1,7 @@
+Galaxy Testing
+==============
+
+The Galaxy code base is large and contains many kinds of tests. Please
+consult the [Galaxy
+wiki](http://wiki.galaxyproject.org/Admin/Running%20Tests) for more
+information on testing Galaxy.
diff -r 9ddb3130b98d450ca2be3f447f171ff5f192b8a1 -r
6673bd3bf4571c4134797077ca85350a6319e444 test/unit/test_tool_loader.py
--- /dev/null
+++ b/test/unit/test_tool_loader.py
@@ -0,0 +1,191 @@
+from tempfile import mkdtemp
+from shutil import rmtree
+import os
+
+from galaxy.util import parse_xml
+from galaxy.tools.loader import template_macro_params, load_tool
+
+def test_loader():
+
+ class TestToolDirectory(object):
+ def __init__(self):
+ self.temp_directory = mkdtemp()
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, tb):
+ rmtree(self.temp_directory)
+
+ def write(self, contents, name="tool.xml"):
+ open(os.path.join(self.temp_directory, name), "w").write(contents)
+
+ def load(self, name="tool.xml", preprocess=True):
+ if preprocess:
+ loader = load_tool
+ else:
+ loader = parse_xml
+ return loader(os.path.join(self.temp_directory, name))
+
+ ## Test simple macro replacement.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <macro name="inputs">
+ <inputs />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load(preprocess=False)
+ assert xml.find("inputs") is None
+ xml = tool_dir.load(preprocess=True)
+ assert xml.find("inputs") is not None
+
+ # Test importing macros from external files
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <import>external.xml</import>
+ </macros>
+</tool>''')
+
+ tool_dir.write('''
+<macros>
+ <macro name="inputs">
+ <inputs />
+ </macro>
+</macros>''', name="external.xml")
+ xml = tool_dir.load(preprocess=False)
+ assert xml.find("inputs") is None
+ xml = tool_dir.load(preprocess=True)
+ assert xml.find("inputs") is not None
+
+ # Test macros with unnamed yield statements.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert xml.find("inputs").find("input").get("name")
== "first_input"
+
+ # Test recursive macro applications.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ <expand macro="second" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ <macro name="second">
+ <input name="second_input" />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
+
+ # Test recursive macro applications.
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs">
+ <input name="first_input" />
+ <expand macro="second" />
+ </expand>
+ <macros>
+ <macro name="inputs">
+ <inputs>
+ <yield />
+ </inputs>
+ </macro>
+ <macro name="second">
+ <expand macro="second_delegate" />
+ </macro>
+ <macro name="second_delegate">
+ <input name="second_input" />
+ </macro>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert
xml.find("inputs").findall("input")[1].get("name") ==
"second_input"
+
+ # Test <xml> is shortcut for macro type="xml"
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <expand macro="inputs" />
+ <macros>
+ <xml name="inputs">
+ <inputs />
+ </xml>
+ </macros>
+</tool>''')
+ xml = tool_dir.load()
+ assert xml.find("inputs") is not None
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <command interpreter="python">tool_wrapper.py
+ #include source=$tool_params
+ </command>
+ <macros>
+ <template name="tool_params">-a 1 -b 2</template>
+ </macros>
+</tool>
+''')
+ xml = tool_dir.load()
+ params_dict = template_macro_params(xml.getroot())
+ assert params_dict['tool_params'] == "-a 1 -b 2"
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <macros>
+ <token name="@CITATION@">The citation.</token>
+ </macros>
+ <help>@CITATION@</help>
+ <another>
+ <tag />
+ </another>
+</tool>
+''')
+ xml = tool_dir.load()
+ help_el = xml.find("help")
+ assert help_el.text == "The citation.", help_el.text
+
+ with TestToolDirectory() as tool_dir:
+ tool_dir.write('''
+<tool>
+ <macros>
+ <token name="@TAG_VAL@">The value.</token>
+ </macros>
+ <another>
+ <tag value="@TAG_VAL@" />
+ </another>
+</tool>
+''')
+ xml = tool_dir.load()
+ tag_el = xml.find("another").find("tag")
+ value = tag_el.get('value')
+ assert value == "The value.", value
Repository URL:
https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.