Final to_json_string/from_json_string elimination in tests.

This commit is contained in:
Dannon Baker
2014-09-09 10:12:40 -04:00
parent 9d85ca9e23
commit 2327f0d946
20 changed files with 45 additions and 45 deletions
+7 -7
View File
@@ -16,7 +16,7 @@ import zipfile
from base.asserts import verify_assertions
from galaxy.util import asbool
from galaxy.util.json import from_json_string
from galaxy.util.json import loads
from galaxy.web import security
from galaxy.web.framework.helpers import iff
from urlparse import urlparse
@@ -56,7 +56,7 @@ class TwillTestCase( unittest.TestCase ):
f = open( self.tool_shed_test_file, 'r' )
text = f.read()
f.close()
self.shed_tools_dict = from_json_string( text )
self.shed_tools_dict = loads( text )
else:
self.shed_tools_dict = {}
self.keepOutdir = os.environ.get( 'GALAXY_TEST_SAVE', '' )
@@ -1293,12 +1293,12 @@ class TwillTestCase( unittest.TestCase ):
def get_running_datasets( self ):
self.visit_url( '/api/histories' )
history_id = from_json_string( self.last_page() )[0][ 'id' ]
history_id = loads( self.last_page() )[0][ 'id' ]
self.visit_url( '/api/histories/%s/contents' % history_id )
jsondata = from_json_string( self.last_page() )
jsondata = loads( self.last_page() )
for history_item in jsondata:
self.visit_url( history_item[ 'url' ] )
item_json = from_json_string( self.last_page() )
item_json = loads( self.last_page() )
if item_json[ 'state' ] in [ 'queued', 'running', 'paused' ]:
return True
return False
@@ -1394,7 +1394,7 @@ class TwillTestCase( unittest.TestCase ):
def json_from_url( self, url, params={} ):
self.visit_url( url, params )
return from_json_string( self.last_page() )
return loads( self.last_page() )
def last_page( self ):
return tc.browser.get_html()
@@ -2510,4 +2510,4 @@ class TwillTestCase( unittest.TestCase ):
self.visit_url( page_url )
data = self.last_page()
return data
return fetcher
return fetcher
+1 -1
View File
@@ -100,7 +100,7 @@ class TestEnvironment( object ):
f = open( self.tool_shed_test_file, 'r' )
text = f.read()
f.close()
shed_tools_dict = from_json_string( text )
shed_tools_dict = loads( text )
except Exception, exc:
log.error( 'Error reading tool shed test file "%s": %s', self.tool_shed_test_file, exc, exc_info=True )
+1 -1
View File
@@ -32,4 +32,4 @@ class UCSCMain( TwillTestCase ):
)
self.run_ucsc_main( track_params, output_params )
self.wait()
self.verify_dataset_correctness( 'GRCm38mm10_chr5_34761740-34912521.fa' )
self.verify_dataset_correctness( 'GRCm38mm10_chr5_34761740-34912521.fa' )
@@ -1 +1 @@
"""Install and test tool shed repositories."""
"""Install and test tool shed repositories."""
@@ -1 +1 @@
'''Tests'''
'''Tests'''
@@ -1 +1 @@
"""Install and test tool shed repositories that contain tools and tool test components."""
"""Install and test tool shed repositories that contain tools and tool test components."""
@@ -42,7 +42,7 @@ import install_and_test_tool_shed_repositories.base.util as install_and_test_bas
from base.tool_shed_util import parse_tool_panel_config
from galaxy.app import UniverseApplication
from galaxy.util.json import from_json_string
from galaxy.util.json import loads
from galaxy.util import asbool
from galaxy.util import unicodify
from galaxy.web import buildapp
@@ -312,7 +312,7 @@ def install_and_test_repositories( app, galaxy_shed_tools_dict_file, galaxy_shed
# Find the path to the test-data directory within the installed repository.
has_test_data, shed_tools_dict = \
parse_tool_panel_config( galaxy_shed_tool_conf_file,
from_json_string( file( galaxy_shed_tools_dict_file, 'r' ).read() ) )
loads( file( galaxy_shed_tools_dict_file, 'r' ).read() ) )
# If the repository has a test-data directory we write the generated shed_tools_dict to a temporary
# file so the functional test framework can find it.
install_and_test_base_util.populate_galaxy_shed_tools_dict_file( galaxy_shed_tools_dict_file,
@@ -1 +1 @@
"""Install and test tool shed repositories of type tool_dependency_definition."""
"""Install and test tool shed repositories of type tool_dependency_definition."""
+1 -1
View File
@@ -1 +1 @@
"""Tool shed functional Tests"""
"""Tool shed functional Tests"""
+5 -5
View File
@@ -15,7 +15,7 @@ import galaxy.util
from base.tool_shed_util import repository_installation_timeout
from base.twilltestcase import TwillTestCase
from galaxy.util.json import from_json_string
from galaxy.util.json import loads
from galaxy.web import security
from tool_shed.util.encoding_util import tool_shed_encode
from tool_shed.util import shed_util_common as suc
@@ -637,7 +637,7 @@ class ShedTwillTestCase( TwillTestCase ):
url = '/api/datatypes?upload_only=false'
self.visit_galaxy_url( url )
html = self.last_page()
datatypes = from_json_string( html )
datatypes = loads( html )
return len( datatypes )
def get_env_sh_path( self, tool_dependency_name, tool_dependency_version, repository ):
@@ -714,7 +714,7 @@ class ShedTwillTestCase( TwillTestCase ):
# Get the current folder's contents.
url = '/repository/open_folder?folder_path=%s' % request_param_path
self.visit_url( url )
file_list = from_json_string( self.last_page() )
file_list = loads( self.last_page() )
returned_file_list = []
if current_path is not None:
returned_file_list.append( current_path )
@@ -753,7 +753,7 @@ class ShedTwillTestCase( TwillTestCase ):
url = '/api/datatypes/sniffers'
self.visit_galaxy_url( url )
html = self.last_page()
sniffers = from_json_string( html )
sniffers = loads( html )
return len( sniffers )
def get_tools_from_repository_metadata( self, repository, include_invalid=False ):
@@ -772,7 +772,7 @@ class ShedTwillTestCase( TwillTestCase ):
tool_guid = urllib.quote_plus( tool_metadata[ 0 ][ 'guid' ], safe='' )
api_url = '/%s' % '/'.join( [ 'api', 'tools', tool_guid ] )
self.visit_galaxy_url( api_url )
tool_dict = from_json_string( self.last_page() )
tool_dict = loads( self.last_page() )
tool_panel_section = tool_dict[ 'panel_section_name' ]
return tool_panel_section
@@ -131,4 +131,4 @@ class TestComplexPriorInstallation( ShedTwillTestCase ):
self.check_repository_dependency( matplotlib_repository, depends_on_repository=numpy_repository )
self.display_manage_repository_page( matplotlib_repository, strings_displayed=[ 'numpy', '1.7', 'package', changeset_revision ] )
@@ -166,4 +166,4 @@ class TestHgWebFeatures( ShedTwillTestCase ):
'Added another line to filtering.py.' ]
strings_not_displayed = [ 'Added a line to filtering.py' ]
self.check_repository_changelog( repository, strings_displayed=strings_displayed, strings_not_displayed=[] )
@@ -192,4 +192,4 @@ class TestRepositoryComponentReviews( ShedTwillTestCase ):
changeset_revision = self.get_repository_tip( repository )
review = self.test_db_util.get_repository_review_by_user_id_changeset_revision( user.id, repository.id, changeset_revision )
self.browse_component_review( review, strings_displayed=strings_displayed )
@@ -227,4 +227,4 @@ class TestRepositoryCitableURLs( ShedTwillTestCase ):
encoded_user_id=None,
encoded_repository_id=None,
strings_displayed=strings_displayed )
@@ -482,4 +482,4 @@ class TestAutomaticDependencyRevision( ShedTwillTestCase ):
self.display_repository_file_contents( repository,
filename='repository_dependencies.xml',
filepath='subfolder',
strings_displayed=[ changeset_revision ] )
strings_displayed=[ changeset_revision ] )
@@ -72,4 +72,4 @@ class TestDependencyDefinitionValidation( ShedTwillTestCase ):
repository = self.test_db_util.get_repository_by_name_and_owner( repository_name, common.test_user_1_name )
assert self.repository_is_new( repository ), 'Uploading an incorrectly defined tool_dependencies.xml resulted in a changeset being generated.'
@@ -116,4 +116,4 @@ class TestRepositoryDependencies( ShedTwillTestCase ):
self.visit_galaxy_url( url, params )
self.check_for_strings( strings_displayed )
strings_not_displayed = [ 'column_maker_1087' ]
self.display_galaxy_browse_repositories_page( strings_not_displayed=strings_not_displayed )
self.display_galaxy_browse_repositories_page( strings_not_displayed=strings_not_displayed )
@@ -175,4 +175,4 @@ class TestComplexPriorInstallation( ShedTwillTestCase ):
numpy_repository = self.test_db_util.get_installed_repository_by_name_owner( numpy_repository_name, common.test_user_1_name )
assert matplotlib_repository.update_time > numpy_repository.update_time, \
'Error: package_numpy_1_7_0170 shows a later update time than package_matplotlib_1_2_0170'
@@ -463,4 +463,4 @@ class TestResetInstalledRepositoryMetadata( ShedTwillTestCase ):
del old_metadata[ 'tool_panel_section' ]
assert repository.metadata == old_metadata, 'Metadata for %s repository %s changed after reset. \nOld: %s\nNew: %s' % \
( repository.status, repository.name, old_metadata, repository.metadata )
+15 -15
View File
@@ -57,7 +57,7 @@ from galaxy.webapps.tool_shed import buildapp as toolshedbuildapp
from galaxy.app import UniverseApplication as GalaxyUniverseApplication
from galaxy.web import buildapp as galaxybuildapp
from galaxy.util import asbool
from galaxy.util.json import to_json_string
from galaxy.util.json import dumps
import nose.core
import nose.config
@@ -182,7 +182,7 @@ def main():
galaxy_test_proxy_port = None
if 'TOOL_SHED_TEST_DBPATH' in os.environ:
shed_db_path = os.environ[ 'TOOL_SHED_TEST_DBPATH' ]
else:
else:
tempdir = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
shed_db_path = os.path.join( tempdir, 'database' )
shed_tool_data_table_conf_file = os.environ.get( 'TOOL_SHED_TEST_TOOL_DATA_TABLE_CONF', os.path.join( tool_shed_test_tmp_dir, 'shed_tool_data_table_conf.xml' ) )
@@ -199,7 +199,7 @@ def main():
os.environ[ 'GALAXY_TEST_TOOL_DATA_PATH' ] = tool_data_path
if 'GALAXY_TEST_DBPATH' in os.environ:
galaxy_db_path = os.environ[ 'GALAXY_TEST_DBPATH' ]
else:
else:
tempdir = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_db_path = os.path.join( tempdir, 'database' )
shed_file_path = os.path.join( shed_db_path, 'files' )
@@ -207,9 +207,9 @@ def main():
hgweb_config_file_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
new_repos_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_tempfiles = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_shed_tool_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_migrated_tool_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_tool_dependency_dir = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_shed_tool_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_migrated_tool_path = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
galaxy_tool_dependency_dir = tempfile.mkdtemp( dir=tool_shed_test_tmp_dir )
os.environ[ 'GALAXY_TEST_TOOL_DEPENDENCY_DIR' ] = galaxy_tool_dependency_dir
hgweb_config_dir = hgweb_config_file_path
os.environ[ 'TEST_HG_WEB_CONFIG_DIR' ] = hgweb_config_dir
@@ -276,8 +276,8 @@ def main():
# Generate the shed_tool_data_table_conf.xml file.
file( shed_tool_data_table_conf_file, 'w' ).write( tool_data_table_conf_xml_template )
os.environ[ 'TOOL_SHED_TEST_TOOL_DATA_TABLE_CONF' ] = shed_tool_data_table_conf_file
# ---- Build Tool Shed Application --------------------------------------------------
toolshedapp = None
# ---- Build Tool Shed Application --------------------------------------------------
toolshedapp = None
# if not toolshed_database_connection.startswith( 'sqlite://' ):
# kwargs[ 'database_engine_option_max_overflow' ] = '20'
if tool_dependency_dir is not None:
@@ -335,7 +335,7 @@ def main():
else:
raise Exception( "Test HTTP server did not return '200 OK' after 10 tries" )
log.info( "Embedded web server started" )
# ---- Optionally start up a Galaxy instance ------------------------------------------------------
if 'TOOL_SHED_TEST_OMIT_GALAXY' not in os.environ:
# Generate the tool_conf.xml file.
@@ -357,7 +357,7 @@ def main():
open( galaxy_shed_data_manager_conf_file, 'wb' ).write( shed_data_manager_conf_xml_template )
galaxy_global_conf = get_webapp_global_conf()
galaxy_global_conf[ '__file__' ] = 'universe_wsgi.ini.sample'
kwargs = dict( allow_user_creation = True,
allow_user_deletion = True,
admin_users = 'test@bx.psu.edu',
@@ -389,15 +389,15 @@ def main():
tool_data_table_config_path = galaxy_tool_data_table_conf_file,
update_integrated_tool_panel = False,
use_heartbeat = False )
# ---- Build Galaxy Application --------------------------------------------------
# ---- Build Galaxy Application --------------------------------------------------
if not galaxy_database_connection.startswith( 'sqlite://' ) and not install_galaxy_database_connection.startswith( 'sqlite://' ):
kwargs[ 'database_engine_option_pool_size' ] = '10'
kwargs[ 'database_engine_option_max_overflow' ] = '20'
galaxyapp = GalaxyUniverseApplication( **kwargs )
log.info( "Embedded Galaxy application started" )
# ---- Run galaxy webserver ------------------------------------------------------
galaxy_server = None
galaxy_global_conf[ 'database_file' ] = galaxy_database_connection
@@ -464,11 +464,11 @@ def main():
test_config = nose.config.Config( env=os.environ, ignoreFiles=ignore_files, plugins=nose.plugins.manager.DefaultPluginManager() )
test_config.configure( sys.argv )
# Run the tests.
result = run_tests( test_config )
result = run_tests( test_config )
success = result.wasSuccessful()
except:
log.exception( "Failure running tests" )
log.info( "Shutting down" )
# ---- Tear down -----------------------------------------------------------
if tool_shed_server: