From f35c0a89d6613fcdda72ee6dc33e7c1484b028fe Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 21 Nov 2013 19:17:12 -0600 Subject: [PATCH] Refactor twill tool test driver to encode hda id earlier. And pass an encoded id to display action in root controller. Would definitely like to simplify or better yet remove root.display if not used anywhere else, it should be coming in through dataset controller. --- lib/galaxy/webapps/galaxy/controllers/root.py | 10 ++++++++-- test/base/twilltestcase.py | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/root.py b/lib/galaxy/webapps/galaxy/controllers/root.py index 704f62e295a..3a4ac83bc45 100644 --- a/lib/galaxy/webapps/galaxy/controllers/root.py +++ b/lib/galaxy/webapps/galaxy/controllers/root.py @@ -172,12 +172,16 @@ class RootController( BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAsso ## ---- Dataset display / editing ---------------------------------------- @web.expose - def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", **kwd ): + def display( self, trans, id=None, hid=None, tofile=None, toext=".txt", encoded_id=None, **kwd ): """Returns data directly into the browser. Sets the mime-type according to the extension. + + Used by the twill tool test driver - used anywhere else? Would like to drop hid + argument and path if unneeded now. Likewise, would like to drop encoded_id=XXX + and use assume id is encoded (likely id wouldn't be coming in encoded if this + is used anywhere else though.) """ - #TODO: unused? #TODO: unencoded id if hid is not None: try: @@ -192,6 +196,8 @@ class RootController( BaseUIController, UsesHistoryMixin, UsesHistoryDatasetAsso else: raise Exception( "No dataset with hid '%d'" % hid ) else: + if encoded_id and not id: + id = trans.security.decode_id( encoded_id ) try: data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id ) except: diff --git a/test/base/twilltestcase.py b/test/base/twilltestcase.py index fc76281e97f..dad6deaafaf 100644 --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -826,8 +826,10 @@ class TwillTestCase( unittest.TestCase ): if ext != test_ext: raise AssertionError( errmsg ) else: + hda_id = self.security.encode_id( elem.get( 'id' ) ) self.home() - self.visit_page( "display?hid=" + hid ) + # See not in controllers/root.py about encoded_id. + self.visit_page( "display?encoded_id=%s" % hda_id ) data = self.last_page() if attributes is not None and attributes.get( "assert_list", None ) is not None: try: @@ -918,7 +920,7 @@ class TwillTestCase( unittest.TestCase ): if base_name is None: base_name = os.path.split(file_name)[-1] temp_name = self.makeTfname(fname=base_name) - self.visit_url( "%s/datasets/%s/display/%s" % ( self.url, self.security.encode_id( hda_id ), base_name ) ) + self.visit_url( "%s/datasets/%s/display/%s" % ( self.url, hda_id, base_name ) ) data = self.last_page() file( temp_name, 'wb' ).write( data ) if self.keepOutdir > '':