PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/test/functional/test_metadata_editing.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 57 lines | 46 code | 3 blank | 8 comment | 2 complexity | f986738d2e285d8ed9b1ab261431a6c4 MD5 | raw file
 1from base.twilltestcase import TwillTestCase
 2from functional import database_contexts
 3import galaxy.model
 4from galaxy.model.orm import (
 5    and_,
 6    desc,
 7)
 8
 9
10class TestMetadataEdit( TwillTestCase ):
11
12    def test_00_metadata_edit( self ):
13        """test_metadata_edit: Testing metadata editing"""
14        sa_session = database_contexts.galaxy_context
15        self.logout()
16        self.login( email='test@bx.psu.edu', username='admin-user' )
17        admin_user = sa_session.query( galaxy.model.User ) \
18                              .filter( galaxy.model.User.table.c.email == 'test@bx.psu.edu' ) \
19                              .one()
20        self.new_history( name='Test Metadata Edit' )
21        history1 = sa_session.query( galaxy.model.History ) \
22                            .filter( and_( galaxy.model.History.table.c.deleted == False,
23                                           galaxy.model.History.table.c.user_id == admin_user.id ) ) \
24                            .order_by( desc( galaxy.model.History.table.c.create_time ) ) \
25                            .first()
26        self.upload_file( '1.bed' )
27        latest_hda = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \
28                              .order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) ) \
29                              .first()
30        self.home()
31        # Due to twill not being able to handle the permissions forms, we'll eliminate
32        # DefaultHistoryPermissions prior to uploading a dataset so that the permission
33        # form will not be displayed on ted edit attributes page.
34        for dp in latest_hda.dataset.actions:
35            sa_session.delete( dp )
36            sa_session.flush()
37        sa_session.refresh( latest_hda.dataset )
38        self.check_history_for_string( '1.bed' )
39        self.check_metadata_for_string( '1.bed uploaded file unspecified (\?) chromCol value="1" selected endCol value="3" is_strandCol value="true" checked', hid=str( latest_hda.hid ) )
40        """test editing attributes"""
41        self.edit_hda_attribute_info( hda_id=str( latest_hda.id ),
42                                      new_name='Testdata',
43                                      new_info="Uploaded my file",
44                                      new_dbkey='hg16',
45                                      new_startcol='6' )
46        self.check_metadata_for_string( 'Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="6" selected', hid=str( latest_hda.hid ) )
47        """test Auto-detecting attributes"""
48        self.auto_detect_metadata( hda_id=str( latest_hda.id ) )
49        self.check_metadata_for_string('Testdata bed Uploaded my file hg16 "bed" selected="yes" "startCol" value="2" selected', hid=str( latest_hda.hid ) )
50        """test converting formats"""
51        self.convert_format( hda_id=str( latest_hda.id ), target_type='gff' )
52        self.check_metadata_for_string( '"gff" selected="yes"', hid=str( latest_hda.hid ) )
53        """test changing data type"""
54        self.change_datatype( hda_id=str( latest_hda.id ), datatype='gff3' )
55        self.check_metadata_for_string( 'gff3', hid=str( latest_hda.hid ) )
56        self.delete_history( id=self.security.encode_id( history1.id ) )
57        self.logout()