mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 02:04:04 +08:00
this is just me
This commit is contained in:
@@ -10,6 +10,9 @@ import twill.commands as tc
|
||||
from twill.other_packages._mechanize_dist import ClientForm
|
||||
from elementtree import ElementTree
|
||||
|
||||
from galaxy.web.controllers.admin import entities, unentities
|
||||
from xml.sax.saxutils import escape, unescape
|
||||
|
||||
buffer = StringIO.StringIO()
|
||||
|
||||
#Force twill to log to a buffer -- FIXME: Should this go to stdout and be captured by nose?
|
||||
@@ -31,7 +34,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.home()
|
||||
self.set_history()
|
||||
|
||||
"""Functions associated with files"""
|
||||
# Functions associated with files
|
||||
def files_diff( self, file1, file2 ):
|
||||
"""Checks the contents of 2 files for differences"""
|
||||
if not filecmp.cmp( file1, file2 ):
|
||||
@@ -83,7 +86,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
errmsg += str( err )
|
||||
raise AssertionError( errmsg )
|
||||
|
||||
"""Functions associated with histories"""
|
||||
# Functions associated with histories
|
||||
def check_history_for_errors( self ):
|
||||
"""Raises an exception if there are errors in a history"""
|
||||
self.visit_page( "history" )
|
||||
@@ -210,7 +213,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
def view_stored_histories( self ):
|
||||
self.visit_page( "history_available" )
|
||||
|
||||
"""Functions associated with datasets (history items) and meta data"""
|
||||
# Functions associated with datasets (history items) and meta data
|
||||
def get_job_stderr( self, id ):
|
||||
self.visit_page( "dataset/stderr?id=%s" % id )
|
||||
return self.last_page()
|
||||
@@ -351,7 +354,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
genome_build = elem.get('dbkey')
|
||||
self.assertTrue( genome_build == dbkey )
|
||||
|
||||
"""Functions associated with user accounts"""
|
||||
# Functions associated with user accounts
|
||||
def create( self, email='test@bx.psu.edu', password='testuser', confirm='testuser' ):
|
||||
self.visit_page( "user/create?email=%s&password=%s&confirm=%s" %(email, password, confirm) )
|
||||
try:
|
||||
@@ -371,7 +374,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
self.check_page_for_string( "You are no longer logged in" )
|
||||
self.home() #Reset our URL for future tests
|
||||
|
||||
"""Functions associated with browsers, cookies, HTML forms and page visits"""
|
||||
# Functions associated with browsers, cookies, HTML forms and page visits
|
||||
def check_page_for_string( self, patt ):
|
||||
"""Looks for 'patt' in the current browser page"""
|
||||
page = self.last_page()
|
||||
@@ -488,7 +491,7 @@ class TwillTestCase( unittest.TestCase ):
|
||||
tc.go("%s" % url)
|
||||
tc.code( 200 )
|
||||
|
||||
"""Functions associated with Galaxy tools"""
|
||||
# Functions associated with Galaxy tools
|
||||
def run_tool( self, tool_id, **kwd ):
|
||||
tool_id = tool_id.replace(" ", "+")
|
||||
"""Runs the tool 'tool_id' and passes it the key/values from the *kwd"""
|
||||
@@ -511,3 +514,73 @@ class TwillTestCase( unittest.TestCase ):
|
||||
else:
|
||||
break
|
||||
self.assertNotEqual(count, maxiter)
|
||||
|
||||
# Dataset Security stuff
|
||||
def create_group( self, name='New Test Group', priority='10' ):
|
||||
"""Create a new group with 1 member"""
|
||||
self.visit_url( "%s/admin/create_group" % self.url )
|
||||
form = tc.show()
|
||||
self.check_page_for_string( "Create Group" )
|
||||
try:
|
||||
tc.fv( "1", "name", name )
|
||||
tc.fv( "1", "priority", priority )
|
||||
# twill version 0.9 still does not allow for easily testing forms that contain
|
||||
# multiple fields with the same name ( e.g., check boxes ). We could attempt to determine
|
||||
# the number of the field on the form and use it instead of the name of the field, but we
|
||||
# would be forced to drop and recreate the database every time we test in order to ensure
|
||||
# the fields will be the same on the form ( since it is dynamically rendered from the database ).
|
||||
tc.fv( "1", "3", "1" ) # 1-based form field 3 is the 1st check box named 'members', user id 1 is test@bx.psu.edu
|
||||
tc.submit( "create_group_button" )
|
||||
except AssertionError, err:
|
||||
errmsg = 'Exception caught attempting to create group: %s' % str( err )
|
||||
raise AssertionError( errmsg )
|
||||
self.home()
|
||||
return form
|
||||
def add_group_member( self, group_id='', group_name='' ):
|
||||
"""Add a member to an existing group"""
|
||||
# twill version 0.9 does not allow for this test
|
||||
self.visit_url( "%s/admin/group_members_edit?group_id=%s&group_name=%s" % ( self.url, group_id, group_name ) )
|
||||
self.check_page_for_string( 'Members of' )
|
||||
try:
|
||||
tc.fv( "1", "", "2" ) # 1-based form field 2 is the 2nd check box named 'members', user id 2 is test2@bx.psu.edu
|
||||
tc.submit( "group_members_edit_button" )
|
||||
except AssertionError, err:
|
||||
errmsg = 'Exception caught attempting to create group: %s' % str( err )
|
||||
raise AssertionError( errmsg )
|
||||
self.home()
|
||||
def mark_group_deleted( self, group_id='' ):
|
||||
"""Delete an existing group"""
|
||||
self.visit_url( "%s/admin/mark_group_deleted?group_id=%s" % ( self.url, group_id ) )
|
||||
self.last_page()
|
||||
self.check_page_for_string( 'The group has been marked as deleted' )
|
||||
self.home()
|
||||
def undelete_group( self, group_id='' ):
|
||||
"""Undelete an existing group"""
|
||||
self.visit_url( "%s/admin/undelete_group?group_id=%s" % ( self.url, group_id ) )
|
||||
self.last_page()
|
||||
self.check_page_for_string( 'The group has been marked as not deleted' )
|
||||
self.home()
|
||||
def purge_group( self, group=None ):
|
||||
"""Purge an existing group"""
|
||||
if not group.deleted:
|
||||
self.mark_group_deleted( group_id=group.id )
|
||||
group_id = str( group.id )
|
||||
group_name = group.name.replace( ' ', '+' )
|
||||
self.visit_url( "%s/admin/deleted_groups" % self.url )
|
||||
self.check_page_for_string( '%s' % group.name )
|
||||
self.visit_url( "%s/admin/purge_group?group_id=%s" % ( self.url, group_id ) )
|
||||
self.last_page()
|
||||
self.check_page_for_string( 'The group has been purged from the database' )
|
||||
self.home()
|
||||
|
||||
# Library stuff
|
||||
def create_library( self, name='', description='' ):
|
||||
"""Create a new library"""
|
||||
name = name.replace( ' ', '+' )
|
||||
description = description.replace( ' ', '+' )
|
||||
try:
|
||||
self.visit_url( "%s/admin/library?name=%s&description=%s&create_library=None" % ( self.url, name, description ) )
|
||||
except AssertionError, err:
|
||||
errmsg = 'Exception caught attempting to create library: %s' % str( err )
|
||||
raise AssertionError( errmsg )
|
||||
self.home()
|
||||
|
||||
@@ -73,6 +73,7 @@ def setup():
|
||||
test_conf = "test.conf",
|
||||
log_destination = "stdout",
|
||||
use_heartbeat=False,
|
||||
admin_users = 'test@bx.psu.edu',
|
||||
global_conf= { "__file__": "universe_wsgi.ini.sample" } )
|
||||
|
||||
log.info( "Embedded Universe application started" )
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import galaxy.model
|
||||
from base.twilltestcase import TwillTestCase
|
||||
|
||||
s = 'You must have Galaxy administrator privileges to use this feature.'
|
||||
|
||||
class TestHistory( TwillTestCase ):
|
||||
def test_00_admin_features_when_not_logged_in( self ):
|
||||
"""Testing admin_features when not logged in"""
|
||||
self.logout()
|
||||
self.visit_url( "%s/admin" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/reload_tool?tool_id=upload1" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/dataset_security" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/groups" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/create_group" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/group_members_edit" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/update_group_members" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/group_dataset_permitted_actions_edit" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/mark_group_deleted" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/purge_group" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/users" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/libraries" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/library" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/folder" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
self.visit_url( "%s/admin/dataset" % self.url )
|
||||
self.check_page_for_string( s )
|
||||
def test_05_login_as_admin( self ):
|
||||
"""Testing logging in as an admin user"""
|
||||
self.login( email='test@bx.psu.edu' ) #This is configured as our admin user
|
||||
self.visit_page( "admin" )
|
||||
self.check_page_for_string( 'Galaxy Administration' )
|
||||
self.logout()
|
||||
# Need to ensure that we have 2 users
|
||||
self.login( email='test2@bx.psu.edu' ) # This will not be an admin user
|
||||
self.visit_page( "admin" )
|
||||
self.check_page_for_string( s )
|
||||
def test_10_create_group( self ):
|
||||
"""Testing creating new group with 1 members"""
|
||||
self.login( email='test@bx.psu.edu' )
|
||||
self.visit_page( "admin/groups" )
|
||||
# the following should have been created when account was created.
|
||||
self.check_page_for_string( 'test@bx.psu.edu private group' )
|
||||
self.create_group( name='New Test Group', priority='10' )
|
||||
self.visit_page( "admin/groups" )
|
||||
self.check_page_for_string( "group_name=New+Test+Group" )
|
||||
# twill version 0.9 still does not allow for the following test
|
||||
#def test_15_add_group_member( self ):
|
||||
# """Testing adding a member to an existing group"""
|
||||
# group = galaxy.model.Group.get_by( name='New Test Group' )
|
||||
# group_id = str( group.id )
|
||||
# group_name = group.name.replace( ' ', '+' )
|
||||
# self.add_group_member( group_id=group_id, group_name=group_name )
|
||||
# self.visit_page( 'admin/group_members?group_id=%s&group_name=%s' % ( group_id, group_name ) )
|
||||
# self.check_page_for_string( 'test@bx.psu.edu' )
|
||||
# self.check_page_for_string( 'test2@bx.psu.edu' )
|
||||
def test_20_delete_group( self ):
|
||||
"""Testing deleting a group"""
|
||||
self.visit_page( "admin/groups" )
|
||||
self.check_page_for_string( "group_name=New+Test+Group" )
|
||||
group = galaxy.model.Group.get_by( name='New Test Group' )
|
||||
group_id = str( group.id )
|
||||
self.mark_group_deleted( group_id=group_id )
|
||||
def test_25_undelete_group( self ):
|
||||
"""Testing undeleting a deleted group"""
|
||||
group = galaxy.model.Group.get_by( name='New Test Group' )
|
||||
group_id = str( group.id )
|
||||
self.undelete_group( group_id=group_id )
|
||||
def test_30_purge_group( self ):
|
||||
"""Testing purging a group"""
|
||||
group = galaxy.model.Group.get_by( name='New Test Group' )
|
||||
self.purge_group( group=group )
|
||||
|
||||
def test_20_create_library( self ):
|
||||
"""Testing creating new library"""
|
||||
self.create_library( name='New Test Library', description='New test Library Description' )
|
||||
self.visit_page( 'admin/libraries' )
|
||||
self.check_page_for_string( "New Test Library" )
|
||||
|
||||
Reference in New Issue
Block a user