Skip to content

Commit

Permalink
Configure a test Galaxy as needed for functional test cases.
Browse files Browse the repository at this point in the history
./run_tests.sh is still good for launching one Galaxy for a bunch of different test cases - but now you can do really simple things like:

```
$ nosetests test/api/test_tours.py
```

In this scenario, the test case class will check if run_tests.sh has created a test driver to use and if it hasn't - one will be made just for the test case (like the new integration tests).
  • Loading branch information
jmchilton committed Nov 30, 2016
1 parent ead8e15 commit 16b027e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/base/driver_util.py
Expand Up @@ -80,6 +80,8 @@ def configure_environment():
if "TOOL_SHED_TEST_FILE_DIR" not in os.environ:
os.environ["TOOL_SHED_TEST_FILE_DIR"] = TOOL_SHED_TEST_DATA

os.environ["GALAXY_TEST_ENVIRONMENT_CONFIGURED"] = "1"


def build_logger():
"""Build a logger for test driver script."""
Expand Down Expand Up @@ -688,7 +690,8 @@ def run_tool_test(self, tool_id, index=0):

def drive_test(test_driver_class):
"""Instantiate driver class, run, and exit appropriately."""
sys.exit(test_driver_class().run())
test_driver = test_driver_class()
sys.exit(test_driver.run())


__all__ = (
Expand Down
17 changes: 17 additions & 0 deletions test/base/twilltestcase.py
Expand Up @@ -21,6 +21,8 @@
from galaxy.tools.verify.test_data import TestDataResolver
from galaxy.web import security

from .driver_util import GalaxyTestDriver

# Force twill to log to a buffer -- FIXME: Should this go to stdout and be captured by nose?
buffer = StringIO()
twill.set_output( buffer )
Expand Down Expand Up @@ -59,6 +61,21 @@ def setUp( self ):
except:
pass

@classmethod
def setUpClass(cls):
"""Configure and start Galaxy for a test."""
cls._test_driver = None

if not os.environ.get("GALAXY_TEST_ENVIRONMENT_CONFIGURED"):
cls._test_driver = GalaxyTestDriver()
cls._test_driver.setup(config_object=cls)

@classmethod
def tearDownClass(cls):
"""Shutdown Galaxy server and cleanup temp directory."""
if cls._test_driver:
cls._test_driver.tear_down()

def get_filename( self, filename, shed_tool_id=None ):
# For tool tests override get_filename to point at an installed tool if shed_tool_id is set.
if shed_tool_id and getattr(self, "shed_tools_dict", None):
Expand Down

0 comments on commit 16b027e

Please sign in to comment.