root/galaxy-central/test/functional/test_library_templates.py

リビジョン 2, 37.5 KB (コミッタ: hatakeyama, 14 年 前)

import galaxy-central

行番号 
1from base.twilltestcase import *
2from base.test_db_util import *
3
4class TestLibraryFeatures( TwillTestCase ):
5    def test_000_initiate_users( self ):
6        """Ensuring all required user accounts exist"""
7        self.logout()
8        self.login( email='test1@bx.psu.edu', username='regular-user1' )
9        global regular_user1
10        regular_user1 = get_user( 'test1@bx.psu.edu' )
11        assert regular_user1 is not None, 'Problem retrieving user with email "test1@bx.psu.edu" from the database'
12        global regular_user1_private_role
13        regular_user1_private_role = get_private_role( regular_user1 )
14        self.logout()
15        self.login( email='test2@bx.psu.edu', username='regular-user2' )
16        global regular_user2
17        regular_user2 = get_user( 'test2@bx.psu.edu' )
18        assert regular_user2 is not None, 'Problem retrieving user with email "test2@bx.psu.edu" from the database'
19        global regular_user2_private_role
20        regular_user2_private_role = get_private_role( regular_user2 )
21        self.logout()
22        self.login( email='test3@bx.psu.edu', username='regular-user3' )
23        global regular_user3
24        regular_user3 = get_user( 'test3@bx.psu.edu' )
25        assert regular_user3 is not None, 'Problem retrieving user with email "test3@bx.psu.edu" from the database'
26        global regular_user3_private_role
27        regular_user3_private_role = get_private_role( regular_user3 )
28        self.logout()
29        self.login( email='test@bx.psu.edu', username='admin-user' )
30        global admin_user
31        admin_user = get_user( 'test@bx.psu.edu' )
32        assert admin_user is not None, 'Problem retrieving user with email "test@bx.psu.edu" from the database'
33        global admin_user_private_role
34        admin_user_private_role = get_private_role( admin_user )
35    def test_005_create_library_templates( self ):
36        """Testing creating several LibraryInformationTemplate form definitions"""
37        # Logged in as admin_user
38        for type in [ 'AddressField', 'CheckboxField', 'SelectField', 'TextArea', 'TextField', 'WorkflowField' ]:
39            form_desc = '%s description' % type
40            num_options = 0
41            if type == 'SelectField':
42                # Pass number of options we want in our SelectField
43                num_options = 2
44            # Create form for library template
45            self.create_form( name=type,
46                              desc=form_desc,
47                              form_type=galaxy.model.FormDefinition.types.LIBRARY_INFO_TEMPLATE,
48                              field_type=type,
49                              num_options=num_options )
50        # Get all of the new form definitions for later use
51        global AddressField_form
52        AddressField_form = get_form( 'AddressField' )
53        global CheckboxField_form
54        CheckboxField_form = get_form( 'CheckboxField' )
55        global SelectField_form
56        SelectField_form = get_form( 'SelectField' )
57        global TextArea_form
58        TextArea_form = get_form( 'TextArea' )
59        global TextField_form
60        TextField_form = get_form( 'TextField' )
61        global WorkflowField_form
62        WorkflowField_form = get_form( 'WorkflowField' )
63    def test_010_create_libraries( self ):
64        """Testing creating a new library for each template"""
65        # Logged in as admin_user
66        # library1 -> AddressField
67        # library2 -> CheckboxField
68        # library3 -> SelectField
69        # library4 -> TextArea
70        # library5 -> TextField
71        # library6 -> WorkflowField
72        for index, form in enumerate( [ AddressField_form, CheckboxField_form, SelectField_form, TextArea_form, TextField_form, WorkflowField_form ] ):
73            name = 'library%s' % str( index + 1 )
74            description = '%s description' % name
75            synopsis = '%s synopsis' % name
76            self.create_library( name=name, description=description, synopsis=synopsis )
77        # Get the libraries for later use
78        global library1
79        library1 = get_library( 'library1', 'library1 description', 'library1 synopsis' )
80        global library2
81        library2 = get_library( 'library2', 'library2 description', 'library2 synopsis' )
82        global library3
83        library3 = get_library( 'library3', 'library3 description', 'library3 synopsis' )
84        global library4
85        library4 = get_library( 'library4', 'library4 description', 'library4 synopsis' )
86        global library5
87        library5 = get_library( 'library5', 'library5 description', 'library5 synopsis' )
88        global library6
89        library6 = get_library( 'library6', 'library6 description', 'library6 synopsis' )
90    def test_015_add_template_to_library1( self ):
91        """Testing add an inheritable template containing an AddressField to library1"""
92        # Logged in as admin_user
93        # Add a template containing an AddressField to library1
94        self.add_library_template( 'library_admin',
95                                   'library',
96                                   self.security.encode_id( library1.id ),
97                                   self.security.encode_id( AddressField_form.id ),
98                                   AddressField_form.name )
99    def test_020_add_folder_to_library1( self ):
100        """Testing adding a folder to library1"""
101        # Logged in as admin_user
102        # Add a folder to library1
103        folder = library1.root_folder
104        name = "folder"
105        description = "folder description"
106        self.add_folder( 'library_admin',
107                         self.security.encode_id( library1.id ),
108                         self.security.encode_id( folder.id ),
109                         name=name,
110                         description=description )
111        global folder1
112        folder1 = get_folder( folder.id, name, description )
113    def test_025_check_library1( self ):
114        """Checking library1 and its root folder"""
115        # Logged in as admin_user
116        self.browse_library( 'library_admin',
117                             self.security.encode_id( library1.id ),
118                             strings_displayed=[ folder1.name, folder1.description ] )
119        # Make sure the template and contents were inherited to folder1
120        self.folder_info( 'library_admin',
121                          self.security.encode_id( folder1.id ),
122                          self.security.encode_id( library1.id ),
123                          strings_displayed=[ AddressField_form.name,
124                                              'This is an inherited template and is not required to be used with this folder' ] )
125    def test_030_add_dataset_to_folder1( self ):
126        """Testing adding a ldda1 to folder1, and adding a new UserAddress on the upload form."""
127        # Logged in as admin_user
128        # The AddressField template should be inherited to the library dataset upload form.  Passing
129        # the value 'new' should submit the form via refresh_on_change and allow new UserAddress information
130        # to be posted as part of the upload.
131        filename = '1.bed'
132        ldda_message = '1.bed message'
133        short_desc = 'Office'
134        self.upload_library_dataset( cntrller='library_admin',
135                                     library_id=self.security.encode_id( library1.id ),
136                                     folder_id=self.security.encode_id( folder1.id ),
137                                     filename=filename,
138                                     file_type='bed',
139                                     dbkey='hg18',
140                                     ldda_message=ldda_message,
141                                     template_refresh_field_contents='new',
142                                     template_fields=[ ( 'field_0_short_desc', short_desc ),
143                                                       ( 'field_0_name', 'Dick' ),
144                                                       ( 'field_0_institution', 'PSU' ),
145                                                       ( 'field_0_address', '32 O Street' ),
146                                                       ( 'field_0_city', 'Anywhere' ),
147                                                       ( 'field_0_state', 'AK' ),
148                                                       ( 'field_0_postal_code', '0000000' ),
149                                                       ( 'field_0_country', 'USA' ) ],
150                                     strings_displayed=[ 'Upload files' ] )
151        global user_address1
152        user_address1 = get_user_address( admin_user, short_desc )
153        assert user_address1 is not None, 'Problem retrieving user_address1 from the database'
154        global ldda1
155        ldda1 = get_latest_ldda_by_name( filename )
156        assert ldda1 is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda1 from the database'
157        self.browse_library( 'library_admin',
158                             self.security.encode_id( library1.id ),
159                             strings_displayed=[ ldda1.name, ldda1.message, admin_user.email ] )
160        # Make sure the library template contents were correctly saved
161        self.ldda_edit_info( 'library_admin',
162                             self.security.encode_id( library1.id ),
163                             self.security.encode_id( folder1.id ),
164                             self.security.encode_id( ldda1.id ),
165                             ldda1.name,
166                             strings_displayed=[ 'Dick' ] )
167    def test_035_edit_contents_of_ldda1_tempplate( self ):
168        """Testing editing the contents of ldda1 AddressField template by adding a new user_address"""
169        short_desc = 'Home'
170        # Now add a new user_address to ldda1
171        self.ldda_edit_info( 'library_admin',
172                             self.security.encode_id( library1.id ),
173                             self.security.encode_id( folder1.id ),
174                             self.security.encode_id( ldda1.id ),
175                             ldda1.name,
176                             template_refresh_field_contents='new',
177                             template_fields=[ ( 'field_0_short_desc', short_desc ),
178                                               ( 'field_0_name', 'Richard' ),
179                                               ( 'field_0_institution', 'PSU' ),
180                                               ( 'field_0_address', '32 O Street' ),
181                                               ( 'field_0_city', 'Anywhere' ),
182                                               ( 'field_0_state', 'AK' ),
183                                               ( 'field_0_postal_code', '0000000' ),
184                                               ( 'field_0_country', 'USA' ) ],
185                             strings_displayed=[ short_desc ] )
186        global user_address2
187        user_address2 = get_user_address( admin_user, short_desc )
188        assert user_address2 is not None, 'Problem retrieving user_address2 from the database'
189    def test_040_edit_contents_of_folder1_template( self ):
190        """Testing editing the contents of folder1 AddressField template"""
191        # Make sure the template and contents were inherited to folder1
192        self.folder_info( 'library_admin',
193                          self.security.encode_id( folder1.id ),
194                          self.security.encode_id( library1.id ),
195                          template_refresh_field_contents=str( user_address2.id ),
196                          strings_displayed=[ AddressField_form.name,
197                                              'This is an inherited template and is not required to be used with this folder' ],
198                          strings_displayed_after_submit=[ 'Richard' ] )
199    def test_045_add_dataset_to_folder1( self ):
200        """Testing adding another ldda to folder1"""
201        # The upload form should now inherit user_address2 on the upload form
202        filename = '2.bed'
203        ldda_message = '2.bed message'
204        self.upload_library_dataset( cntrller='library_admin',
205                                     library_id=self.security.encode_id( library1.id ),
206                                     folder_id=self.security.encode_id( folder1.id ),
207                                     filename=filename,
208                                     file_type='bed',
209                                     dbkey='hg18',
210                                     ldda_message=ldda_message,
211                                     strings_displayed=[ 'Upload files' ] )
212        # Make sure user_address2 is associated with ldda.
213        self.ldda_edit_info( 'library_admin',
214                             self.security.encode_id( library1.id ),
215                             self.security.encode_id( folder1.id ),
216                             self.security.encode_id( ldda1.id ),
217                             ldda1.name,
218                             strings_displayed=[ user_address2.desc ] )
219    def test_050_add_template_to_library2( self ):
220        """ Testing add an inheritable template containing an CheckboxField to library2"""
221        # Add a template containing an CheckboxField to library1
222        self.add_library_template( 'library_admin',
223                                   'library',
224                                   self.security.encode_id( library2.id ),
225                                   self.security.encode_id( CheckboxField_form.id ),
226                                   CheckboxField_form.name )
227        # Check the CheckboxField to make sure the template contents are inherited
228        self.library_info( 'library_admin',
229                            self.security.encode_id( library2.id ),
230                            template_fields = [ ( 'field_0', '1' ) ] )
231    def test_055_add_folder2_to_library2( self ):
232        """Testing adding a folder to library2"""
233        # Logged in as admin_user
234        # Add a folder to library2
235        folder = library2.root_folder
236        name = "folder"
237        description = "folder description"
238        self.add_folder( 'library_admin',
239                         self.security.encode_id( library2.id ),
240                         self.security.encode_id( folder.id ),
241                         name=name,
242                         description=description )
243        global folder2
244        folder2 = get_folder( folder.id, name, description )
245    def test_060_check_library2( self ):
246        """Checking library2 and its root folder"""
247        # Logged in as admin_user
248        self.browse_library( 'library_admin',
249                             self.security.encode_id( library2.id ),
250                             strings_displayed=[ folder2.name, folder2.description ] )
251    def test_065_save_folder2_inherited_template( self ):
252        """Saving the inherited template for folder2"""
253        # Logged in as admin_user
254        # Save the inherited template
255        self.folder_info( cntrller='library_admin',
256                          folder_id=self.security.encode_id( folder2.id ),
257                          library_id=self.security.encode_id( library2.id ),
258                          template_fields=[ ( "field_0", '1' ) ],
259                          strings_displayed=[ CheckboxField_form.name,
260                                              'This is an inherited template and is not required to be used with this folder' ] )
261    def test_070_add_ldda_to_folder2( self ):
262        """
263        Testing adding a new library dataset to library2's folder, making sure the CheckboxField is
264        checked on the upload form.
265        """
266        # Logged in as admin_user
267        filename = '1.bed'
268        ldda_message = '1.bed message'
269        self.upload_library_dataset( cntrller='library_admin',
270                                     library_id=self.security.encode_id( library2.id ),
271                                     folder_id=self.security.encode_id( folder2.id ),
272                                     filename=filename,
273                                     file_type='bed',
274                                     dbkey='hg18',
275                                     ldda_message=ldda_message,
276                                     strings_displayed=[ 'CheckboxField', 'checked' ] )
277        ldda = get_latest_ldda_by_name( filename )
278        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
279        self.browse_library( 'library_admin',
280                             self.security.encode_id( library2.id ),
281                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
282        # Make sure the library template contents were correctly saved
283        self.ldda_edit_info( 'library_admin',
284                             self.security.encode_id( library2.id ),
285                             self.security.encode_id( folder2.id ),
286                             self.security.encode_id( ldda.id ),
287                             ldda.name,
288                             strings_displayed=[ 'CheckboxField', 'checked' ] )
289    def test_080_add_template_to_library3( self ):
290        """ Testing add an inheritable template containing an SelectField to library3"""
291        # Logged in as admin_user
292        self.add_library_template( 'library_admin',
293                                   'library',
294                                   self.security.encode_id( library3.id ),
295                                   self.security.encode_id( SelectField_form.id ),
296                                   SelectField_form.name )
297        # Select the 2nd option in the SelectField to make sure the template contents are inherited
298        # SelectField option names are zero-based
299        self.library_info( 'library_admin',
300                            self.security.encode_id( library3.id ),
301                            template_fields=[ ( 'field_0', 'Option1' ) ] )
302    def test_085_add_folder3_to_library3( self ):
303        """Testing adding a folder to library3"""
304        # Logged in as admin_user
305        # Add a folder to library3
306        folder = library3.root_folder
307        name = "folder"
308        description = "folder description"
309        self.add_folder( 'library_admin',
310                         self.security.encode_id( library3.id ),
311                         self.security.encode_id( folder.id ),
312                         name=name,
313                         description=description )
314        global folder3
315        folder3 = get_folder( folder.id, name, description )
316    def test_090_check_library3( self ):
317        """Checking library3 and its root folder"""
318        # Logged in as admin_user
319        self.browse_library( 'library_admin',
320                             self.security.encode_id( library3.id ),
321                             strings_displayed=[ folder3.name, folder3.description ] )
322    def test_095_save_folder3_inherited_template( self ):
323        """Saving the inherited template for folder3"""
324        # Logged in as admin_user
325        # Save the inherited template
326        self.folder_info( cntrller='library_admin',
327                          folder_id=self.security.encode_id( folder3.id ),
328                          library_id=self.security.encode_id( library3.id ),
329                          template_fields=[ ( "field_0", 'Option1' ) ],
330                          strings_displayed=[ SelectField_form.name,
331                                              'This is an inherited template and is not required to be used with this folder',
332                                              'Option1' ] )
333    def test_100_add_ldda_to_folder3( self ):
334        """
335        Testing adding a new library dataset to library3's folder,
336        making sure the SelectField setting is correct on the upload form.
337        """
338        filename = '3.bed'
339        ldda_message = '3.bed message'
340        # Logged in as admin_user
341        self.upload_library_dataset( cntrller='library_admin',
342                                     library_id=self.security.encode_id( library3.id ),
343                                     folder_id=self.security.encode_id( folder3.id ),
344                                     filename=filename,
345                                     file_type='bed',
346                                     dbkey='hg18',
347                                     ldda_message=ldda_message,
348                                     strings_displayed=[ 'SelectField', 'selected>Option1' ] )
349        ldda = get_latest_ldda_by_name( filename )
350        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
351        self.browse_library( 'library_admin',
352                             self.security.encode_id( library3.id ),
353                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
354        # Make sure the library template contents were correctly saved
355        self.ldda_edit_info( 'library_admin',
356                             self.security.encode_id( library3.id ),
357                             self.security.encode_id( folder3.id ),
358                             self.security.encode_id( ldda.id ),
359                             ldda.name,
360                             strings_displayed=[ 'SelectField', 'Option1' ] )
361        # Import a dataset from the current history
362        filename = '8.bed'
363        self.new_history( name='import with SelectField' )
364        self.upload_file( filename )
365        hda = get_latest_hda()
366        self.upload_library_dataset( cntrller='library_admin',
367                                     library_id=self.security.encode_id( library3.id ),
368                                     folder_id=self.security.encode_id( folder3.id ),
369                                     upload_option='import_from_history',
370                                     hda_ids=self.security.encode_id( hda.id ),
371                                     strings_displayed=[ '<input type="hidden" name="field_0" value="Option1"/>' ] )
372        ldda = get_latest_ldda_by_name( filename )
373        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
374        self.browse_library( 'library_admin',
375                             self.security.encode_id( library3.id ),
376                             strings_displayed=[ ldda.name, admin_user.email ] )
377        # Make sure the library template contents were correctly saved
378        self.ldda_edit_info( 'library_admin',
379                             self.security.encode_id( library3.id ),
380                             self.security.encode_id( folder3.id ),
381                             self.security.encode_id( ldda.id ),
382                             ldda.name,
383                             strings_displayed=[ 'SelectField', 'Option1' ] )
384    def test_105_add_template_to_library4( self ):
385        """ Testing add an inheritable template containing an TextArea to library4"""
386        # Logged in as admin_user
387        # Add an inheritable template to library4
388        self.add_library_template( 'library_admin',
389                                   'library',
390                                   self.security.encode_id( library4.id ),
391                                   self.security.encode_id( TextArea_form.id ),
392                                   TextArea_form.name )
393        # Select the 2nd option in the SelectField to make sure the template contents are inherited
394        self.library_info( 'library_admin',
395                            self.security.encode_id( library4.id ),
396                            template_fields=[ ('field_0', 'This text should be inherited' ) ] )
397    def test_110_add_folder4_to_library4( self ):
398        """Testing adding a folder to library4"""
399        # Logged in as admin_user
400        # Add a folder to library4
401        folder = library4.root_folder
402        name = "folder"
403        description = "folder description"
404        self.add_folder( 'library_admin',
405                         self.security.encode_id( library4.id ),
406                         self.security.encode_id( folder.id ),
407                         name=name,
408                         description=description )
409        global folder4
410        folder4 = get_folder( folder.id, name, description )
411    def test_115_save_folder4_inherited_template( self ):
412        """Saving the inherited template for folder4"""
413        # Logged in as admin_user
414        # Save the inherited template
415        self.folder_info( cntrller='library_admin',
416                          folder_id=self.security.encode_id( folder4.id ),
417                          library_id=self.security.encode_id( library4.id ),
418                          template_fields=[ ( "field_0", 'This text should be inherited' ) ],
419                          strings_displayed=[ TextArea_form.name,
420                                              'This is an inherited template and is not required to be used with this folder',
421                                              'This text should be inherited' ] )
422    def test_120_add_ldda_to_folder4( self ):
423        """
424        Testing adding a new library dataset to library4's folder,
425        making sure the TextArea setting is correct on the upload form.
426        """
427        filename = '4.bed'
428        ldda_message = '4.bed message'
429        # Logged in as admin_user
430        self.upload_library_dataset( cntrller='library_admin',
431                                     library_id=self.security.encode_id( library4.id ),
432                                     folder_id=self.security.encode_id( folder4.id ),
433                                     filename=filename,
434                                     file_type='bed',
435                                     dbkey='hg18',
436                                     ldda_message=ldda_message,
437                                     strings_displayed=[ 'TextArea', 'This text should be inherited' ] )
438        ldda = get_latest_ldda_by_name( filename )
439        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
440        self.browse_library( 'library_admin',
441                             self.security.encode_id( library4.id ),
442                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
443        # Make sure the library template contents were correctly saved
444        self.ldda_edit_info( 'library_admin',
445                             self.security.encode_id( library4.id ),
446                             self.security.encode_id( folder4.id ),
447                             self.security.encode_id( ldda.id ),
448                             ldda.name,
449                             strings_displayed=[ 'TextArea', 'This text should be inherited' ] )
450    def test_125_add_template_to_library5( self ):
451        """ Testing add an inheritable template containing an TextField to library5"""
452        # Add an inheritable template to library5
453        self.add_library_template( 'library_admin',
454                                   'library',
455                                   self.security.encode_id( library5.id ),
456                                   self.security.encode_id( TextField_form.id ),
457                                   TextField_form.name )
458        # Select the 2nd option in the SelectField to make sure the template contents are inherited
459        self.library_info( 'library_admin',
460                           self.security.encode_id( library5.id ),
461                           template_fields=[ ( 'field_0', 'This text should be inherited' ) ] )
462    def test_130_add_folder5_to_library5( self ):
463        """Testing adding a folder to library5"""
464        # Logged in as admin_user
465        # Add a folder to library5
466        folder = library5.root_folder
467        name = "folder"
468        description = "folder description"
469        self.add_folder( 'library_admin',
470                         self.security.encode_id( library5.id ),
471                         self.security.encode_id( folder.id ),
472                         name=name,
473                         description=description )
474        global folder5
475        folder5 = get_folder( folder.id, name, description )
476    def test_135_save_folder5_inherited_template( self ):
477        """Saving the inherited template for folder5"""
478        # Logged in as admin_user
479        # Save the inherited template
480        self.folder_info( cntrller='library_admin',
481                          folder_id=self.security.encode_id( folder5.id ),
482                          library_id=self.security.encode_id( library5.id ),
483                          template_fields=[ ( "field_0", 'This text should be inherited' ) ],
484                          strings_displayed=[ TextField_form.name,
485                                              'This is an inherited template and is not required to be used with this folder',
486                                              'This text should be inherited' ] )
487    def test_140_add_ldda_to_folder5( self ):
488        """
489        Testing adding a new library dataset to library5's folder,
490        making sure the TextField setting is correct on the upload form.
491        """
492        # Logged in as admin_user
493        filename = '5.bed'
494        ldda_message = '5.bed message'
495        self.upload_library_dataset( cntrller='library_admin',
496                                     library_id=self.security.encode_id( library5.id ),
497                                     folder_id=self.security.encode_id( folder5.id ),
498                                     filename=filename,
499                                     file_type='bed',
500                                     dbkey='hg18',
501                                     ldda_message=ldda_message,
502                                     strings_displayed=[ 'TextField', 'This text should be inherited' ] )
503        ldda = get_latest_ldda_by_name( filename )
504        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
505        self.browse_library( 'library_admin',
506                             self.security.encode_id( library5.id ),
507                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
508        # Make sure the library template contents were correctly saved
509        self.ldda_edit_info( 'library_admin',
510                             self.security.encode_id( library5.id ),
511                             self.security.encode_id( folder5.id ),
512                             self.security.encode_id( ldda.id ),
513                             ldda.name,
514                             strings_displayed=[ 'TextField', 'This text should be inherited' ] )
515    def test_145_edit_library5_template_layout( self ):
516        """Test editing the layout of library5's template"""
517        # Currently there is only a TextField, and we'll add a TextArea.
518        self.edit_template( 'library_admin',
519                            'library',
520                            self.security.encode_id( library5.id ),
521                            field_type='TextArea',
522                            field_name_1=TextArea_form.name,
523                            field_helptext_1='%s help' % TextArea_form.name,
524                            field_default_1='%s default' % TextArea_form.name )
525    def test_150_add_ldda_to_library5( self ):
526        """
527        Testing adding a new library dataset to library5's folder,
528        making sure the TextField and new TextArea settings are
529        correct on the upload form.
530        """
531        filename = '6.bed'
532        ldda_message = '6.bed message'
533        # Logged in as admin_user
534        self.upload_library_dataset( cntrller='library_admin',
535                                     library_id=self.security.encode_id( library5.id ),
536                                     folder_id=self.security.encode_id( library5.root_folder.id ),
537                                     filename=filename,
538                                     file_type='bed',
539                                     dbkey='hg18',
540                                     ldda_message=ldda_message,
541                                     strings_displayed=[ 'TextField',
542                                                         'This text should be inherited',
543                                                         'TextArea' ] )
544        ldda = get_latest_ldda_by_name( filename )
545        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
546        self.browse_library( 'library_admin',
547                             self.security.encode_id( library5.id ),
548                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
549        # Make sure the library template contents were correctly saved
550        self.ldda_edit_info( 'library_admin',
551                             self.security.encode_id( library5.id ),
552                             self.security.encode_id( library5.root_folder.id ),
553                             self.security.encode_id( ldda.id ),
554                             ldda.name,
555                             strings_displayed=[ 'TextField',
556                                                 'This text should be inherited',
557                                                 'TextArea' ] )
558    def test_155_add_template_to_library6( self ):
559        """ Testing add an inheritable template containing an WorkflowField to library6"""
560        # Add an inheritable template to library6
561        # We won't select an option since we have no workflow to select
562        self.add_library_template( 'library_admin',
563                                   'library',
564                                   self.security.encode_id( library6.id ),
565                                   self.security.encode_id( WorkflowField_form.id ),
566                                   WorkflowField_form.name )
567    def test_160_add_folder6_to_library6( self ):
568        """Testing adding a folder to library6"""
569        # Logged in as admin_user
570        # Add a folder to library5
571        folder = library6.root_folder
572        name = "folder"
573        description = "folder description"
574        self.add_folder( 'library_admin',
575                         self.security.encode_id( library6.id ),
576                         self.security.encode_id( folder.id ),
577                         name=name,
578                         description=description )
579        global folder6
580        folder6 = get_folder( folder.id, name, description )
581    def test_165_save_folder6_inherited_template( self ):
582        """Saving the inherited template for folder6"""
583        # Logged in as admin_user
584        # Save the inherited template - we won't select an option since we have no workflow to select
585        self.folder_info( cntrller='library_admin',
586                          folder_id=self.security.encode_id( folder6.id ),
587                          library_id=self.security.encode_id( library6.id ),
588                          template_fields=[ ( "field_0", 'none' ) ],
589                          strings_displayed=[ WorkflowField_form.name,
590                                              'This is an inherited template and is not required to be used with this folder',
591                                              'none' ] )
592    def test_170_add_ldda_to_folder6( self ):
593        """
594        Testing adding a new library dataset to library6's folder,
595        making sure the WorkflowField setting is correct on the upload form.
596        """
597        # Logged in as admin_user
598        filename = '7.bed'
599        ldda_message = '7.bed message'
600        self.upload_library_dataset( cntrller='library_admin',
601                                     library_id=self.security.encode_id( library6.id ),
602                                     folder_id=self.security.encode_id( folder6.id ),
603                                     filename=filename,
604                                     file_type='bed',
605                                     dbkey='hg18',
606                                     ldda_message=ldda_message,
607                                     strings_displayed=[ 'WorkflowField', 'none' ] )
608        ldda = get_latest_ldda_by_name( filename )
609        assert ldda is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda from the database'
610        self.browse_library( 'library_admin',
611                             self.security.encode_id( library6.id ),
612                             strings_displayed=[ ldda.name, ldda.message, admin_user.email ] )
613        # Make sure the library template contents were correctly saved
614        self.ldda_edit_info( 'library_admin',
615                             self.security.encode_id( library6.id ),
616                             self.security.encode_id( folder6.id ),
617                             self.security.encode_id( ldda.id ),
618                             ldda.name,
619                             strings_displayed=[ 'WorkflowField', 'none' ] )
620    def test_999_reset_data_for_later_test_runs( self ):
621        """Reseting data to enable later test runs to pass"""
622        # Logged in as admin_user
623        ##################
624        # Delete all form definitions
625        ##################
626        for form in [ AddressField_form, CheckboxField_form, SelectField_form, TextArea_form, TextField_form, WorkflowField_form ]:
627            self.mark_form_deleted( self.security.encode_id( form.form_definition_current.id ) )
628        ##################
629        # Mark all user_addresses deleted
630        ##################
631        for user_address in [ user_address1, user_address2 ]:
632            mark_obj_deleted( user_address )
633        ##################
634        # Purge all libraries
635        ##################
636        for library in [ library1, library2, library3, library4, library5, library6 ]:
637            self.delete_library_item( 'library_admin',
638                                      self.security.encode_id( library.id ),
639                                      self.security.encode_id( library.id ),
640                                      library.name,
641                                      item_type='library' )
642            self.purge_library( self.security.encode_id( library.id ), library.name )
643        ##################
644        # Make sure all users are associated only with their private roles
645        ##################
646        for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
647            refresh( user )
648            if len( user.roles) != 1:
649                raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
650        self.logout()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。