From 2327f0d9468930831f4e75eb8f2a23d9353d3297 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Tue, 9 Sep 2014 10:12:40 -0400 Subject: [PATCH] Final to_json_string/from_json_string elimination in tests. --- test/base/twilltestcase.py | 14 ++++----- test/casperjs/server_env.py | 2 +- test/functional/test_ucsc_table_browser.py | 2 +- .../__init__.py | 2 +- .../functional/__init__.py | 2 +- .../repositories_with_tools/__init__.py | 2 +- .../functional_tests.py | 4 +-- .../tool_dependency_definitions/__init__.py | 2 +- test/tool_shed/__init__.py | 2 +- test/tool_shed/base/twilltestcase.py | 10 +++---- ...170_complex_prior_installation_required.py | 2 +- .../functional/test_0310_hg_push_from_api.py | 2 +- ...ository_component_review_access_control.py | 2 +- ...test_0420_citable_urls_for_repositories.py | 2 +- .../test_0460_upload_to_repository.py | 2 +- ...t_0480_tool_dependency_xml_verification.py | 2 +- ...install_updated_repository_dependencies.py | 2 +- ...170_complex_prior_installation_required.py | 2 +- .../test_1300_reset_all_metadata.py | 2 +- test/tool_shed/functional_tests.py | 30 +++++++++---------- 20 files changed, 45 insertions(+), 45 deletions(-) diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index 121a6cb7e9e..70502be2a54 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -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 \ No newline at end of file + return fetcher diff --git a/test/casperjs/server_env.py b/test/casperjs/server_env.py index 895d536e347..c8ec3e64e23 100644 --- a/test/casperjs/server_env.py +++ b/test/casperjs/server_env.py @@ -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 ) diff --git a/test/functional/test_ucsc_table_browser.py b/test/functional/test_ucsc_table_browser.py index 20f89a86a11..8bb705e3245 100644 --- a/test/functional/test_ucsc_table_browser.py +++ b/test/functional/test_ucsc_table_browser.py @@ -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' ) \ No newline at end of file + self.verify_dataset_correctness( 'GRCm38mm10_chr5_34761740-34912521.fa' ) diff --git a/test/install_and_test_tool_shed_repositories/__init__.py b/test/install_and_test_tool_shed_repositories/__init__.py index 589f49784c6..6e46a4fd653 100644 --- a/test/install_and_test_tool_shed_repositories/__init__.py +++ b/test/install_and_test_tool_shed_repositories/__init__.py @@ -1 +1 @@ -"""Install and test tool shed repositories.""" \ No newline at end of file +"""Install and test tool shed repositories.""" diff --git a/test/install_and_test_tool_shed_repositories/functional/__init__.py b/test/install_and_test_tool_shed_repositories/functional/__init__.py index 6381479a356..fddd6e00638 100644 --- a/test/install_and_test_tool_shed_repositories/functional/__init__.py +++ b/test/install_and_test_tool_shed_repositories/functional/__init__.py @@ -1 +1 @@ -'''Tests''' \ No newline at end of file +'''Tests''' diff --git a/test/install_and_test_tool_shed_repositories/repositories_with_tools/__init__.py b/test/install_and_test_tool_shed_repositories/repositories_with_tools/__init__.py index f310522e417..5b5af9783dc 100644 --- a/test/install_and_test_tool_shed_repositories/repositories_with_tools/__init__.py +++ b/test/install_and_test_tool_shed_repositories/repositories_with_tools/__init__.py @@ -1 +1 @@ -"""Install and test tool shed repositories that contain tools and tool test components.""" \ No newline at end of file +"""Install and test tool shed repositories that contain tools and tool test components.""" diff --git a/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py b/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py index d18253ef3fd..5ac31d9d610 100644 --- a/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py +++ b/test/install_and_test_tool_shed_repositories/repositories_with_tools/functional_tests.py @@ -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, diff --git a/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/__init__.py b/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/__init__.py index 96961325193..e14087faad8 100644 --- a/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/__init__.py +++ b/test/install_and_test_tool_shed_repositories/tool_dependency_definitions/__init__.py @@ -1 +1 @@ -"""Install and test tool shed repositories of type tool_dependency_definition.""" \ No newline at end of file +"""Install and test tool shed repositories of type tool_dependency_definition.""" diff --git a/test/tool_shed/__init__.py b/test/tool_shed/__init__.py index fc330eaaefe..1f89ece4ddb 100644 --- a/test/tool_shed/__init__.py +++ b/test/tool_shed/__init__.py @@ -1 +1 @@ -"""Tool shed functional Tests""" \ No newline at end of file +"""Tool shed functional Tests""" diff --git a/test/tool_shed/base/twilltestcase.py b/test/tool_shed/base/twilltestcase.py index cb8577e83a5..3d49066031a 100644 --- a/test/tool_shed/base/twilltestcase.py +++ b/test/tool_shed/base/twilltestcase.py @@ -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 diff --git a/test/tool_shed/functional/test_0170_complex_prior_installation_required.py b/test/tool_shed/functional/test_0170_complex_prior_installation_required.py index ab6296027e6..b6dee1978ff 100644 --- a/test/tool_shed/functional/test_0170_complex_prior_installation_required.py +++ b/test/tool_shed/functional/test_0170_complex_prior_installation_required.py @@ -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 ] ) - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_0310_hg_push_from_api.py b/test/tool_shed/functional/test_0310_hg_push_from_api.py index 6ecce3ffa19..e6b45a8e5b3 100644 --- a/test/tool_shed/functional/test_0310_hg_push_from_api.py +++ b/test/tool_shed/functional/test_0310_hg_push_from_api.py @@ -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=[] ) - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_0410_repository_component_review_access_control.py b/test/tool_shed/functional/test_0410_repository_component_review_access_control.py index 041cbc3bbdc..68701a59e5b 100644 --- a/test/tool_shed/functional/test_0410_repository_component_review_access_control.py +++ b/test/tool_shed/functional/test_0410_repository_component_review_access_control.py @@ -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 ) - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_0420_citable_urls_for_repositories.py b/test/tool_shed/functional/test_0420_citable_urls_for_repositories.py index a76c4bf33be..4c4e0709167 100644 --- a/test/tool_shed/functional/test_0420_citable_urls_for_repositories.py +++ b/test/tool_shed/functional/test_0420_citable_urls_for_repositories.py @@ -227,4 +227,4 @@ class TestRepositoryCitableURLs( ShedTwillTestCase ): encoded_user_id=None, encoded_repository_id=None, strings_displayed=strings_displayed ) - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_0460_upload_to_repository.py b/test/tool_shed/functional/test_0460_upload_to_repository.py index f0f9897ca44..66d073fe1a2 100644 --- a/test/tool_shed/functional/test_0460_upload_to_repository.py +++ b/test/tool_shed/functional/test_0460_upload_to_repository.py @@ -482,4 +482,4 @@ class TestAutomaticDependencyRevision( ShedTwillTestCase ): self.display_repository_file_contents( repository, filename='repository_dependencies.xml', filepath='subfolder', - strings_displayed=[ changeset_revision ] ) \ No newline at end of file + strings_displayed=[ changeset_revision ] ) diff --git a/test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py b/test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py index 8317f4a6ff4..8dd4189023f 100644 --- a/test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py +++ b/test/tool_shed/functional/test_0480_tool_dependency_xml_verification.py @@ -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.' - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py b/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py index 4b4ded0840e..abb0c52638f 100644 --- a/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py +++ b/test/tool_shed/functional/test_1087_install_updated_repository_dependencies.py @@ -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 ) \ No newline at end of file + self.display_galaxy_browse_repositories_page( strings_not_displayed=strings_not_displayed ) diff --git a/test/tool_shed/functional/test_1170_complex_prior_installation_required.py b/test/tool_shed/functional/test_1170_complex_prior_installation_required.py index 21677ecf4d7..25294d3b125 100644 --- a/test/tool_shed/functional/test_1170_complex_prior_installation_required.py +++ b/test/tool_shed/functional/test_1170_complex_prior_installation_required.py @@ -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' - \ No newline at end of file + diff --git a/test/tool_shed/functional/test_1300_reset_all_metadata.py b/test/tool_shed/functional/test_1300_reset_all_metadata.py index 91188c7ce86..d72141f311e 100644 --- a/test/tool_shed/functional/test_1300_reset_all_metadata.py +++ b/test/tool_shed/functional/test_1300_reset_all_metadata.py @@ -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 ) - \ No newline at end of file + diff --git a/test/tool_shed/functional_tests.py b/test/tool_shed/functional_tests.py index c7036252791..2ba6aea7780 100644 --- a/test/tool_shed/functional_tests.py +++ b/test/tool_shed/functional_tests.py @@ -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: