From afbadc0b0b8f4f87fd906235dca789897b953b03 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 15 May 2015 15:47:35 -0400 Subject: [PATCH 1/2] Fix function names for dynamic tool test functions. When finding methods to invoke it seems nose uses the raw function name instead of the class's attribute name (I guess this terminology makes sense), but when reporting results it uses the latter. Synchronizing these names therefore allows calling specific tool test methods from the command-line. This change is required to implement galaxyproject/planemo#145. --- test/functional/test_toolbox.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/functional/test_toolbox.py b/test/functional/test_toolbox.py index d707690c4c3..99d7c78d9f4 100644 --- a/test/functional/test_toolbox.py +++ b/test/functional/test_toolbox.py @@ -263,13 +263,18 @@ def build_tests( app=None, testing_shed_tools=False, master_api_key=None, user_a baseclasses = ( ToolTestCase, ) namespace = dict() for j, testdef in enumerate( tool.tests ): + test_function_name = 'test_tool_%06d' % j + def make_test_method( td ): def test_tool( self ): self.do_it( td ) + test_tool.__name__ = test_function_name + return test_tool + test_method = make_test_method( testdef ) test_method.__doc__ = "%s ( %s ) > %s" % ( tool.name, tool.id, testdef.name ) - namespace[ 'test_tool_%06d' % j ] = test_method + namespace[ test_function_name ] = test_method namespace[ 'shed_tool_id' ] = shed_tool_id namespace[ 'master_api_key' ] = master_api_key namespace[ 'user_api_key' ] = user_api_key From daae1876c39f361bbfd1ea3cd0a5c394196df294 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Sat, 27 Jun 2015 10:28:28 -0400 Subject: [PATCH 2/2] Fix managers to pass context necessary down the chain when purging. This should fix at least one quota calc error. Fix another bug in hda manager regarding quota reduction -- quota usage must be calculated prior to actually purging, otherwise the disk usage is 0 and this does nothing. Slight refactoring in manager purge -- we don't need to pass the user via context since we can just grab it where applicable from the history. Fix purge when handling an anonymous user --- lib/galaxy/managers/hdas.py | 10 +++++++--- lib/galaxy/managers/histories.py | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/galaxy/managers/hdas.py b/lib/galaxy/managers/hdas.py index e724d660a59..18e9955e906 100644 --- a/lib/galaxy/managers/hdas.py +++ b/lib/galaxy/managers/hdas.py @@ -143,14 +143,18 @@ class HDAManager( datasets.DatasetAssociationManager, return ldda.to_history_dataset_association( history, add_to_history=True ) # .... deletion and purging - def purge( self, hda, current_user=None, flush=True ): + def purge( self, hda, flush=True): """ Purge this HDA and the dataset underlying it. """ + user = hda.history.user or None + quota_amount_reduction = 0 + if user: + quota_amount_reduction = hda.quota_amount( user ) super( HDAManager, self ).purge( hda, flush=flush ) # decrease the user's space used - if current_user: - current_user.total_disk_usage -= hda.quota_amount( current_user ) + if quota_amount_reduction: + user.total_disk_usage -= quota_amount_reduction return hda # .... states diff --git a/lib/galaxy/managers/histories.py b/lib/galaxy/managers/histories.py index 14e53aa230d..1ebe9269bdb 100644 --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -82,7 +82,6 @@ class HistoryManager( sharable.SharableModelManager, deletable.PurgableManagerMi Purge this history and all HDAs, Collections, and Datasets inside this history. """ self.hda_manager.dataset_manager.error_unless_dataset_purge_allowed() - # First purge all the datasets for hda in history.datasets: if not hda.purged: