commit/galaxy-central: inithello: Fix for failing upload tool functional tests.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/3d569f107f1d/ Changeset: 3d569f107f1d User: inithello Date: 2013-04-25 21:16:23 Summary: Fix for failing upload tool functional tests. Affected #: 1 file diff -r 1fa287b15af5dab0ac84545835752b4f87e87328 -r 3d569f107f1d449b028fc4d5390dd8d07fdf26ce test/base/twilltestcase.py --- a/test/base/twilltestcase.py +++ b/test/base/twilltestcase.py @@ -242,7 +242,20 @@ # Wait for upload processing to finish (TODO: this should be done in each test case instead) self.wait() + def json_from_url( self, url ): + self.visit_url( url ) + return from_json_string( self.last_page() ) + # Functions associated with histories + def get_history_from_api( self, encoded_history_id=None ): + if encoded_history_id is None: + history = self.get_latest_history() + encoded_history_id = history[ 'id' ] + return self.json_from_url( '/api/histories/%s/contents' % encoded_history_id ) + + def get_latest_history( self ): + return self.json_from_url( '/api/histories' )[ 0 ] + def check_history_for_errors( self ): """Raises an exception if there are errors in a history""" self.home() @@ -317,43 +330,29 @@ Uses history page JSON to determine whether this history is empty (i.e. has no undeleted datasets). """ - def has_no_undeleted_hdas( hda_list ): - if not len( hda_list ): - return True - for hda in hda_list: - if not( hda[ 'deleted' ] or hda[ 'purged' ] ): - return False - return True - try: - self.check_history_json( r'\bhdas\s*=\s*(.*);', has_no_undeleted_hdas ) - except AssertionError, exc: - log.error( 'history is not empty' ) - raise exc + return len( self.get_history_from_api() ) == 0 def check_hda_json_for_key_value( self, hda_id, key, value, use_string_contains=False ): """ - Uses history page JSON to determine whether the current history: - (1) has an hda with hda_id, - (2) that hda has a JSON var named 'key', - (3) that var 'key' == value - If use_string_contains=True, this will search for value in var 'key' - instead of testing for an entire, exact match (string only). + Uses the history API to determine whether the current history: + (1) Has a history dataset with the required ID. + (2) That dataset has the required key. + (3) The contents of that key match the provided value. + If use_string_contains=True, this will perform a substring match, otherwise an exact match. """ #TODO: multi key, value - def hda_has_key_value( hda_list ): - for hda in hda_list: - # if we found the hda and there's a var in the json named key - if( ( hda[ 'id' ] == hda_id ) - and ( key in hda ) ): - var = hda[ key ] - # test for partial string containment if str and requested - if( ( type( var ) == str ) - and ( use_string_contains ) ): - return ( value in var ) - # otherwise, test for equivalence - return ( var == value ) - return False - self.check_history_json( r'\bhdas\s*=\s*(.*);', hda_has_key_value ) + hda = dict() + for history_item in self.get_history_from_api(): + if history_item[ 'id' ] == hda_id: + hda = self.json_from_url( history_item[ 'url' ] ) + break + if hda: + if key in hda: + if use_string_contains: + return value in hda[ key ] + else: + return value == hda[ key ] + return False def clear_history( self ): """Empties a history of all datasets""" Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org