PageRenderTime 36ms CodeModel.GetById 17ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

/test/functional/test_tags.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 77 lines | 60 code | 7 blank | 10 comment | 4 complexity | 80e23b5dc73dbc6de9adbe66188ec498 MD5 | raw file
 1from base.twilltestcase import TwillTestCase
 2from base.test_db_util import (
 3    get_user,
 4    get_private_role,
 5    get_latest_history_for_user,
 6    get_latest_hda,
 7)
 8
 9history1 = None
10admin_user = None
11
12
13class TestTags( TwillTestCase ):
14
15    # TODO: Add more functional test coverage for tags
16    def test_000_initiate_users( self ):
17        """Ensuring all required user accounts exist"""
18        self.logout()
19        self.login( email='test1@bx.psu.edu', username='regular-user1' )
20        global regular_user1
21        regular_user1 = get_user( 'test1@bx.psu.edu' )
22        assert regular_user1 is not None, 'Problem retrieving user with email "test1@bx.psu.edu" from the database'
23        global regular_user1_private_role
24        regular_user1_private_role = get_private_role( regular_user1 )
25        self.logout()
26        self.login( email='test2@bx.psu.edu', username='regular-user2' )
27        global regular_user2
28        regular_user2 = get_user( 'test2@bx.psu.edu' )
29        assert regular_user2 is not None, 'Problem retrieving user with email "test2@bx.psu.edu" from the database'
30        global regular_user2_private_role
31        regular_user2_private_role = get_private_role( regular_user2 )
32        self.logout()
33        self.login( email='test3@bx.psu.edu', username='regular-user3' )
34        global regular_user3
35        regular_user3 = get_user( 'test3@bx.psu.edu' )
36        assert regular_user3 is not None, 'Problem retrieving user with email "test3@bx.psu.edu" from the database'
37        global regular_user3_private_role
38        regular_user3_private_role = get_private_role( regular_user3 )
39        self.logout()
40        self.login( email='test@bx.psu.edu', username='admin-user' )
41        global admin_user
42        admin_user = get_user( 'test@bx.psu.edu' )
43        assert admin_user is not None, 'Problem retrieving user with email "test@bx.psu.edu" from the database'
44        global admin_user_private_role
45        admin_user_private_role = get_private_role( admin_user )
46
47    def test_005_add_tag_to_history( self ):
48        """Testing adding a tag to a history"""
49        # Logged in as admin_user
50        # Create a new, empty history named anonymous
51        name = 'anonymous'
52        self.new_history( name=name )
53        global history1
54        history1 = get_latest_history_for_user( admin_user )
55        self.add_tag( self.security.encode_id( history1.id ),
56                      'History',
57                      'history.mako',
58                      'hello' )
59        self.get_tags( self.security.encode_id( history1.id ), 'History' )
60        self.check_page_for_string( 'tags : {"hello": ""}' )
61
62    def test_010_add_tag_to_history_item( self ):
63        """Testing adding a tag to a history item"""
64        # Logged in as admin_user
65        self.upload_file( '1.bed' )
66        latest_hda = get_latest_hda()
67        self.add_tag( self.security.encode_id( latest_hda.id ),
68                      'HistoryDatasetAssociation',
69                      'edit_attributes.mako',
70                      'goodbye' )
71        self.check_hda_attribute_info( 'tags : {"goodbye"' )
72
73    def test_999_reset_data_for_later_test_runs( self ):
74        """Reseting data to enable later test runs to to be valid"""
75        # logged in as admin_user
76        # Delete histories
77        self.delete_history( id=self.security.encode_id( history1.id ) )