From 3135ffa5fcfea8392de321cdb74653dc0ea4d010 Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Wed, 2 Jun 2010 14:24:48 -0400 Subject: [PATCH] Fix for LibraryDatasetDatasetAssociation objects when created by importing a history item iinto a library, the copied_from_history_dataset_association_id will now be kept. Add a get_display_name() method to the LibraryDatasetDatasetAssociation class. Fix for the test_forms_and_requests.py functional test script, purge all created libraries created during the tests so following test runs will test correctly. --- lib/galaxy/model/__init__.py | 17 ++++++++++++++--- test/functional/test_forms_and_requests.py | 10 ++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 16dee231ac3..a168490db3c 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -932,7 +932,7 @@ class LibraryFolder( object ): return [ ld for ld in self.datasets if not ld.library_dataset_dataset_association.dataset.deleted ] @property def active_datasets( self ): - # This needs to be a list + # This needs to be a list return [ ld.library_dataset_dataset_association.dataset for ld in self.datasets if not ld.library_dataset_dataset_association.deleted ] def get_display_name( self ): # Library folder name can be either a string or a unicode object. If string, @@ -997,8 +997,10 @@ class LibraryDatasetDatasetAssociation( DatasetInstance ): # FIXME: sa_session is must be passed to DataSetInstance if the create_dataset # parameter in kwd is True so that the new object can be flushed. Is there a better way? DatasetInstance.__init__( self, sa_session=sa_session, **kwd ) - self.copied_from_history_dataset_association = copied_from_history_dataset_association - self.copied_from_library_dataset_dataset_association = copied_from_library_dataset_dataset_association + if copied_from_history_dataset_association: + self.copied_from_history_dataset_association_id = copied_from_history_dataset_association.id + if copied_from_library_dataset_dataset_association: + self.copied_from_library_dataset_dataset_association_id = copied_from_library_dataset_dataset_association.id self.library_dataset = library_dataset self.user = user def to_history_dataset_association( self, target_history, parent_id = None, add_to_history = False ): @@ -1085,6 +1087,15 @@ class LibraryDatasetDatasetAssociation( DatasetInstance ): else: return template.get_widgets( trans.user ) return [] + def get_display_name( self ): + """ + LibraryDatasetDatasetAssociation name can be either a string or a unicode object. + If string, convert to unicode object assuming 'utf-8' format. + """ + ldda_name = self.name + if isinstance( ldda_name, str ): + ldda_name = unicode( ldda_name, 'utf-8' ) + return ldda_name class LibraryInfoAssociation( object ): def __init__( self, library, form_definition, info, inheritable=False ): diff --git a/test/functional/test_forms_and_requests.py b/test/functional/test_forms_and_requests.py index 7ee409628a8..b633acf4b89 100644 --- a/test/functional/test_forms_and_requests.py +++ b/test/functional/test_forms_and_requests.py @@ -382,6 +382,16 @@ class TestFormsAndRequests( TwillTestCase ): sa_session.delete( a ) sa_session.flush() ################## + # Purge all libraries + ################## + for library in [ library_one ]: + self.delete_library_item( 'library_admin', + self.security.encode_id( library.id ), + self.security.encode_id( library.id ), + library.name, + item_type='library' ) + self.purge_library( self.security.encode_id( library.id ), library.name ) + ################## # Eliminate all non-private roles ################## for role in [ role_one, role_two ]: