mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allow GALAXY_TEST_FILE_DIR to a comma-separate list.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
LIST_SEP = re.compile("\s*,\s*")
|
||||
|
||||
|
||||
class TestDataResolver(object):
|
||||
|
||||
def __init__(self, env_var, environ=os.environ):
|
||||
file_dirs = environ.get(env_var, None)
|
||||
if file_dirs:
|
||||
self.file_dirs = LIST_SEP.split(file_dirs)
|
||||
else:
|
||||
self.file_dirs = []
|
||||
|
||||
def get_filename(self, name):
|
||||
if not self.file_dirs:
|
||||
filename = None
|
||||
else:
|
||||
filename = os.path.join(self.file_dirs[0], name)
|
||||
# For backward compat. returning first path if none
|
||||
# exist - though I don't know if this function is ever
|
||||
# actually used in a context where one should return
|
||||
# a file even if it doesn't exist (e.g. a prefix or
|
||||
# or something) - I am pretty sure it is not used in
|
||||
# such a fashion in the context of tool tests.
|
||||
if not os.path.exists(filename):
|
||||
for file_dir in self.file_dirs[1:]:
|
||||
query_filename = os.path.join(file_dir, name)
|
||||
if os.path.exists(query_filename):
|
||||
filename = query_filename
|
||||
return os.path.abspath(filename)
|
||||
@@ -15,6 +15,7 @@ import urllib
|
||||
import zipfile
|
||||
|
||||
from base.asserts import verify_assertions
|
||||
from base.test_data import TestDataResolver
|
||||
from galaxy.util import asbool
|
||||
from galaxy.util.json import loads
|
||||
from galaxy.web import security
|
||||
@@ -49,7 +50,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.host = os.environ.get( 'GALAXY_TEST_HOST' )
|
||||
self.port = os.environ.get( 'GALAXY_TEST_PORT' )
|
||||
self.url = "http://%s:%s" % ( self.host, self.port )
|
||||
self.file_dir = os.environ.get( 'GALAXY_TEST_FILE_DIR', None )
|
||||
self.test_data_resolver = TestDataResolver( 'GALAXY_TEST_FILE_DIR' )
|
||||
self.tool_shed_test_file = os.environ.get( 'GALAXY_TOOL_SHED_TEST_FILE', None )
|
||||
if self.tool_shed_test_file:
|
||||
f = open( self.tool_shed_test_file, 'r' )
|
||||
@@ -1224,11 +1225,9 @@ class TwillTestCase( unittest.TestCase ):
|
||||
def get_filename( self, filename, shed_tool_id=None ):
|
||||
if shed_tool_id and self.shed_tools_dict:
|
||||
file_dir = self.shed_tools_dict[ shed_tool_id ]
|
||||
if not file_dir:
|
||||
file_dir = self.file_dir
|
||||
else:
|
||||
file_dir = self.file_dir
|
||||
return os.path.abspath( os.path.join( file_dir, filename ) )
|
||||
if file_dir:
|
||||
return os.path.abspath( os.path.join( file_dir, filename))
|
||||
return self.test_data_resolver.get_filename( filename )
|
||||
|
||||
def get_form_controls( self, form ):
|
||||
formcontrols = []
|
||||
|
||||
Reference in New Issue
Block a user