1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/d2717865114c/
Changeset: d2717865114c
User: davebgx
Date: 2014-04-21 21:42:22
Summary: Fix functional tests for history functions.
Affected #: 2 files
diff -r 9856484a0dcf784ff4bf9e087c14de2e4d6d9506 -r d2717865114c0c577fcd508201acf5eeac2cc54a test/base/twilltestcase.py
--- a/test/base/twilltestcase.py
+++ b/test/base/twilltestcase.py
@@ -270,11 +270,31 @@
return from_json_string( self.last_page() )
# Functions associated with histories
- def get_history_from_api( self, encoded_history_id=None ):
+ def get_history_from_api( self, encoded_history_id=None, show_deleted=None, show_details=False ):
if encoded_history_id is None:
history = self.get_latest_history()
encoded_history_id = history[ 'id' ]
- return self.json_from_url( '/api/histories/%s/contents' % encoded_history_id )
+ params = dict()
+ if show_deleted is not None:
+ params[ 'deleted' ] = show_deleted
+ api_url = '/api/histories/%s/contents?%s' % ( encoded_history_id, urllib.urlencode( params ) )
+ json_data = self.json_from_url( api_url )
+ if show_deleted is not None:
+ hdas = []
+ for hda in json_data:
+ if show_deleted:
+ hdas.append( hda )
+ else:
+ if not hda[ 'deleted' ]:
+ hdas.append( hda )
+ json_data = hdas
+ if show_details:
+ params[ 'details' ] = ','.join( [ hda[ 'id' ] for hda in json_data ] )
+ api_url = '/api/histories/%s/contents?%s' % ( encoded_history_id, urllib.urlencode( params ) )
+ json_data = self.json_from_url( api_url )
+ log.debug( 'detailed url: %s' % api_url )
+ log.debug( 'detailed json data: %s' % json_data )
+ return json_data
def get_latest_history( self ):
return self.json_from_url( '/api/histories' )[ 0 ]
@@ -325,33 +345,21 @@
raise AssertionError( errmsg )
self.home()
- def check_history_json( self, pattern, check_fn, show_deleted=None, multiline=True ):
+ def check_history_json( self, check_fn, show_deleted=None ):
"""
Tries to find a JSON string in the history page using the regex pattern,
parse it, and assert check_fn returns True when called on that parsed
data.
"""
- self.home()
- if show_deleted:
- self.visit_page( "history?show_deleted=True" )
- elif show_deleted == False:
- self.visit_page( "history?show_deleted=False" )
- else:
- self.visit_page( "history" )
- json_data = {}
try:
- tc.find( pattern, flags=( 'm' if multiline else '' ) )
- # twill stores the regex match in a special stack variable
- match = twill.namespaces.get_twill_glocals()[1][ '__match__' ]
- json_data = from_json_string( match )
- assert check_fn( json_data ), 'failed check_fn: %s' % ( check_fn.func_name )
-
- except Exception, exc:
- log.error( exc, exc_info=True )
+ json_data = self.get_history_from_api( show_deleted=show_deleted, show_details=True )
+ check_result = check_fn( json_data )
+ assert check_result, 'failed check_fn: %s (got %s)' % ( check_fn.func_name, str( check_result ) )
+ except Exception, e:
+ log.exception( e )
log.debug( 'json_data: %s', ( '\n' + pprint.pformat( json_data ) if json_data else '(no match)' ) )
fname = self.write_temp_file( tc.browser.get_html() )
- errmsg = ( "json '%s' could not be found or failed check_fn" % ( pattern ) +
- "\npage content written to '%s'" % ( fname ) )
+ errmsg = ( "json could not be read\npage content written to '%s'" % ( fname ) )
raise AssertionError( errmsg )
self.home()
diff -r 9856484a0dcf784ff4bf9e087c14de2e4d6d9506 -r d2717865114c0c577fcd508201acf5eeac2cc54a test/functional/test_history_functions.py
--- a/test/functional/test_history_functions.py
+++ b/test/functional/test_history_functions.py
@@ -665,7 +665,7 @@
if hda[ 'id' ] == self.security.encode_id( hda_2_bed.id ):
return ( not hda[ 'accessible' ] )
return False
- self.check_history_json( r'\bhdaJSON\s*=\s*(.*);', hda_2_bed_is_inaccessible )
+ self.check_history_json( hda_2_bed_is_inaccessible )
# Admin users can view all datasets ( using the history/view feature ), so make sure 2.bed is accessible to the admin
self.logout()
@@ -738,28 +738,26 @@
.order_by( desc( galaxy.model.HistoryDatasetAssociation.table.c.create_time ) )
.first() )
- # delete that item and make sure the 'history empty' message shows
+ # delete that item and make sure the history is not empty
self.home()
log.info( 'deleting last hda' )
self.delete_history_item( str( latest_hda.id ) )
- # check the historyPanel settings.show_deleted for a null json value (no show_deleted in query string)
- self.check_history_json( r'\bshow_deleted\s*:\s*(.*),', lambda x: x == None )
+ # check the number of items returned from the api
+ self.check_history_json( lambda x: len( x ) != 0 )
# reload this history with the show_deleted flag set in the query string
# the deleted dataset should be there with the proper 'deleted' text
- self.home()
log.info( 'turning show_deleted on' )
- #self.visit_url( "%s/history/?show_deleted=True" % self.url )
- # check the historyPanel settings.show_deleted for a true json value
- self.check_history_json( r'\bshow_deleted\s*:\s*(.*),', lambda x: x == True, show_deleted=True )
+ #self.visit_url( "/api/histories/<id>/contents?deleted=True" )
+ # check the number of items returned from the api
+ self.check_history_json( lambda x: len( x ) != 0, show_deleted=True )
# reload this history again with the show_deleted flag set TO FALSE in the query string
- # make sure the 'history empty' message shows
- self.home()
+ # make sure the history is empty
log.info( 'turning show_deleted off' )
- #self.visit_url( "%s/history/?show_deleted=False" % self.url )
- # check the historyPanel settings.show_deleted for a false json value
- self.check_history_json( r'\bshow_deleted\s*:\s*(.*),', lambda x: x == False, show_deleted=False )
+ #self.visit_url( "/api/histories/<id>/contents?deleted=False" )
+ # check the number of items returned from the api
+ self.check_history_json( lambda x: len( x ) == 0, show_deleted=False )
# delete this history
self.delete_history( self.security.encode_id( latest_history.id ) )
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/a247bdaecba9/
Changeset: a247bdaecba9
User: davebgx
Date: 2014-04-21 18:41:05
Summary: Fix for registering an account with custom user information when only one custom user info form is defined. Fix editing user info when custom user info forms are defined. Fix functional tests for user info.
Affected #: 5 files
diff -r 990979ee295e919be24b112a7cad215641c729ad -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 lib/galaxy/webapps/galaxy/controllers/user.py
--- a/lib/galaxy/webapps/galaxy/controllers/user.py
+++ b/lib/galaxy/webapps/galaxy/controllers/user.py
@@ -623,7 +623,6 @@
@web.expose
def create( self, trans, cntrller='user', redirect_url='', refresh_frames=[], **kwd ):
params = util.Params( kwd )
-
# If the honeypot field is not empty we are dealing with a bot.
honeypot_field = params.get( 'bear_field', '' )
if honeypot_field != '':
@@ -927,6 +926,7 @@
user_type_fd_id_select_field=user_type_fd_id_select_field,
user_info_forms=user_info_forms,
user_type_form_definition=user_type_form_definition,
+ user_type_fd_id=user_type_fd_id,
widgets=widgets,
addresses=addresses,
show_filter=show_filter,
diff -r 990979ee295e919be24b112a7cad215641c729ad -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 templates/user/register.mako
--- a/templates/user/register.mako
+++ b/templates/user/register.mako
@@ -139,7 +139,7 @@
all Galaxy project mailing lists</a>.</p></div>
%endif
- %if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) > 1:
+ %if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) >= 1:
<div class="form-row"><label>User type</label>
${user_type_fd_id_select_field.get_html()}
diff -r 990979ee295e919be24b112a7cad215641c729ad -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 templates/webapps/galaxy/user/manage_info.mako
--- a/templates/webapps/galaxy/user/manage_info.mako
+++ b/templates/webapps/galaxy/user/manage_info.mako
@@ -13,13 +13,13 @@
<div class="toolForm"><form name="user_info" id="user_info" action="${h.url_for( controller='user', action='edit_info', cntrller=cntrller, user_id=trans.security.encode_id( user.id ) )}" method="post" ><div class="toolFormTitle">User information</div>
- %if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) > 1:
+ %if user_type_fd_id_select_field and len( user_type_fd_id_select_field.options ) >= 1:
<div class="form-row"><label>User type:</label>
${user_type_fd_id_select_field.get_html()}
</div>
%else:
- <input type="hidden" name="user_type_fd_id" value="${trans.security.encode_id( user_type_form_definition.id )}"/>
+ <input type="hidden" name="user_type_fd_id" value="${trans.security.encode_id( user_type_fd_id )}"/>
%endif
%for field in widgets:
<div class="form-row">
diff -r 990979ee295e919be24b112a7cad215641c729ad -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 test/base/twilltestcase.py
--- a/test/base/twilltestcase.py
+++ b/test/base/twilltestcase.py
@@ -1039,17 +1039,17 @@
strings_displayed=[], strings_displayed_after_submit=[] ):
# This method creates a new user with associated info
self.visit_url( "%s/user/create?cntrller=%s&use_panels=False" % ( self.url, cntrller ) )
- tc.fv( "1", "email", email )
- tc.fv( "1", "password", password )
- tc.fv( "1", "confirm", password )
- tc.fv( "1", "username", username )
+ tc.fv( "registration", "email", email )
+ tc.fv( "registration", "password", password )
+ tc.fv( "registration", "confirm", password )
+ tc.fv( "registration", "username", username )
if user_type_fd_id:
# The user_type_fd_id SelectField requires a refresh_on_change
- self.refresh_form( 'user_type_fd_id', user_type_fd_id )
- tc.fv( "1", "password", password )
- tc.fv( "1", "confirm", password )
+ self.refresh_form( 'user_type_fd_id', user_type_fd_id, form_id='registration' )
+ tc.fv( "registration", "password", password )
+ tc.fv( "registration", "confirm", password )
for index, ( field_name, info_value ) in enumerate( user_info_values ):
- tc.fv( "1", field_name, info_value )
+ tc.fv( "registration", field_name, info_value )
for check_str in strings_displayed:
self.check_page_for_string( check_str)
tc.submit( "create_user_button" )
@@ -1345,12 +1345,12 @@
pass
tc.submit( button )
- def refresh_form( self, control_name, value, form_no=0, **kwd ):
+ def refresh_form( self, control_name, value, form_no=0, form_id=None, **kwd ):
"""Handles Galaxy's refresh_on_change for forms without ultimately submitting the form"""
# control_name is the name of the form field that requires refresh_on_change, and value is
# the value to which that field is being set.
for i, f in enumerate( self.showforms() ):
- if i == form_no:
+ if i == form_no or ( form_id is not None and f.id == form_id ):
break
try:
control = f.find_control( name=control_name )
@@ -1684,6 +1684,7 @@
num_fields=1, num_options=0, field_name='1_field_name', strings_displayed=[],
strings_displayed_after_submit=[] ):
"""Create a new form definition."""
+ strings_displayed_after_submit.extend( [ name, description, form_type ] )
self.visit_url( "%s/forms/create_form_definition" % self.url )
for check_str in strings_displayed:
self.check_page_for_string( check_str )
diff -r 990979ee295e919be24b112a7cad215641c729ad -r a247bdaecba956f1a1b74713ba7fd9ec100e0342 test/functional/test_user_info.py
--- a/test/functional/test_user_info.py
+++ b/test/functional/test_user_info.py
@@ -1,9 +1,8 @@
from base.twilltestcase import *
from base.test_db_util import *
+class TestUserInfo( TwillTestCase ):
-# TODO: Functional tests start failing at 020, fix or eliminate rest of tests.
-class TestUserInfo( TwillTestCase ):
def test_000_initiate_users( self ):
"""Ensuring all required user accounts exist"""
self.logout()
@@ -34,91 +33,65 @@
assert admin_user is not None, 'Problem retrieving user with email "test(a)bx.psu.edu" from the database'
global admin_user_private_role
admin_user_private_role = get_private_role( admin_user )
+
def test_005_create_user_info_forms( self ):
"""Testing creating a new user info form and editing it"""
# Logged in as admin_user
# Create a the first form
- name = "Student"
- desc = "This is Student user info form's description"
- form_type = get_user_info_form_definition()
- self.create_form( name=name,
- description=desc,
- form_type=form_type,
+ self.create_form( name='Student',
+ description="This is Student user info form's description",
+ form_type=get_user_info_form_definition(),
num_fields=0,
strings_displayed=[ 'Create a new form definition' ],
- strings_displayed_after_submit=[ name, desc, form_type ] )
- tmp_form = get_form( name )
- # field names
- global affiliation_field_name
- affiliation_field_name = 'affiliation'
- global organization_field_name
- organization_field_name = 'name_of_organization'
- global feedback_field_name
- feedback_field_name = 'contact_for_feedback'
+ strings_displayed_after_submit=[] )
+ tmp_form = get_form( 'Student' )
# Add fields to the form
field_dicts = [ dict( label='Affiliation',
desc='The type of organization you are affiliated with',
type='SelectField',
required='optional',
selectlist=[ 'Educational', 'Research', 'Commercial' ],
- name=affiliation_field_name ),
+ name='affiliation' ),
dict( label='Name of Organization',
desc='',
type='TextField',
required='optional',
- name=organization_field_name ),
+ name='name_of_oganization' ),
dict( label='Contact for feedback',
desc='',
type='CheckboxField',
required='optional',
- name=feedback_field_name ) ]
+ name='contact_for_feedback' ) ]
self.edit_form( id=self.security.encode_id( tmp_form.current.id ),
field_dicts=field_dicts,
field_index=len( tmp_form.fields ),
- strings_displayed=[ 'Edit form definition "%s"' % name ],
- strings_displayed_after_submit=[ "The form '%s' has been updated with the changes." % name ] )
+ strings_displayed=[ 'Edit form definition "Student"' ],
+ strings_displayed_after_submit=[ "The form 'Student' has been updated with the changes." ] )
# Get the form_definition object for later tests
global form_one
- form_one = get_form( name )
- assert form_one is not None, 'Problem retrieving form named "%s" from the database' % name
+ form_one = get_form( 'Student' )
+ assert form_one is not None, 'Problem retrieving form named "Student" from the database'
assert len( form_one.fields ) == len( tmp_form.fields ) + len( field_dicts )
# Create the second form
- name = "Researcher"
- desc = "This is Researcher user info form's description"
- self.create_form( name=name,
- description=desc,
- form_type=form_type,
+ self.create_form( name='Researcher',
+ description="This is Researcher user info form's description",
+ form_type=get_user_info_form_definition(),
num_fields=0,
strings_displayed=[ 'Create a new form definition' ],
- strings_displayed_after_submit=[ name, desc, form_type ] )
- tmp_form = get_form( name )
+ strings_displayed_after_submit=[] )
+ tmp_form = get_form( 'Researcher' )
# Add fields to the form
- field_dicts = [ dict( label='Affiliation',
- desc='The type of organization you are affiliated with',
- type='SelectField',
- required='optional',
- selectlist=[ 'Educational', 'Research', 'Commercial' ],
- name=affiliation_field_name ),
- dict( label='Name of Organization',
- desc='',
- type='TextField',
- required='optional',
- name=organization_field_name ),
- dict( label='Contact for feedback',
- desc='',
- type='CheckboxField',
- required='optional',
- name=feedback_field_name ) ]
self.edit_form( id=self.security.encode_id( tmp_form.current.id ),
field_dicts=field_dicts,
field_index=len( tmp_form.fields ),
- strings_displayed=[ 'Edit form definition "%s"' % name ],
- strings_displayed_after_submit=[ "The form '%s' has been updated with the changes." % name ] )
+ strings_displayed=[ 'Edit form definition "Researcher"' ],
+ strings_displayed_after_submit=[ "The form 'Researcher' has been updated with the changes." ] )
# Get the form_definition object for later tests
global form_two
- form_two = get_form( name )
- assert form_two is not None, 'Problem retrieving form named "%s" from the database' % name
+ form_two = get_form( 'Researcher' )
+ assert form_two is not None, 'Problem retrieving form named "Researcher" from the database'
assert len( form_two.fields ) == len( tmp_form.fields ) + len( field_dicts )
+
def test_010_user_reqistration_multiple_user_info_forms( self ):
"""Testing user registration with multiple user info forms"""
# Logged in as admin_user
@@ -129,9 +102,9 @@
email = 'test11(a)bx.psu.edu'
password = 'testuser'
username = 'test11'
- user_info_values=[ ( affiliation_field_name, 'Educational' ),
- ( organization_field_name, 'Penn State' ),
- ( feedback_field_name, '1' ) ]
+ user_info_values=[ ( 'affiliation', 'Educational' ),
+ ( 'name_of_oganization', 'Penn State' ),
+ ( 'contact_for_feedback', '1' ) ]
self.create_user_with_info( cntrller='admin',
email=email,
password=password,
@@ -147,12 +120,13 @@
self.logout()
self.login( email=regular_user11.email, username=username )
global form_checkbox_field3_string
- form_checkbox_field3_string = '<input type="checkbox" id="%s" name="%s" value="true" checked="checked">' % ( feedback_field_name, feedback_field_name )
+ form_checkbox_field3_string = '<input type="checkbox" id="contact_for_feedback" name="contact_for_feedback" value="true" checked="checked">'
self.edit_user_info( cntrller='user',
strings_displayed=[ "Manage User Information",
user_info_values[0][1],
user_info_values[1][1],
form_checkbox_field3_string ] )
+
def test_015_user_reqistration_single_user_info_forms( self ):
"""Testing user registration with a single user info form"""
# Logged in as regular_user_11
@@ -166,9 +140,9 @@
email = 'test12(a)bx.psu.edu'
password = 'testuser'
username = 'test12'
- user_info_values=[ ( affiliation_field_name, 'Educational' ),
- ( organization_field_name, 'Penn State' ),
- ( feedback_field_name, '1' ) ]
+ user_info_values=[ ( 'affiliation', 'Educational' ),
+ ( 'name_of_oganization', 'Penn State' ),
+ ( 'contact_for_feedback', '1' ) ]
self.create_user_with_info( cntrller='admin',
email=email,
password=password,
@@ -188,10 +162,12 @@
user_info_values[0][1],
user_info_values[1][1],
form_checkbox_field3_string ] )
+
def test_020_edit_user_info( self ):
"""Testing editing user info as a regular user"""
# Logged in as regular_user_12
# Test changing email and user name - first try an invalid user name
+ regular_user12 = get_user( 'test12(a)bx.psu.edu' )
self.edit_user_info( cntrller='user',
new_email='test12_new(a)bx.psu.edu',
new_username='test12_new',
@@ -214,11 +190,12 @@
# Test logging in with new email and password
self.login( email=regular_user12.email, password='testuser#' )
# Test editing the user info
- new_user_info_values=[ ( affiliation_field_name, 'Educational' ),
- ( organization_field_name, 'Penn State' ) ]
+ new_user_info_values=[ ( 'affiliation', 'Educational' ),
+ ( 'name_of_oganization', 'Penn State' ) ]
self.edit_user_info( cntrller='user',
info_values=new_user_info_values,
strings_displayed_after_submit=[ "The user information has been updated with the changes" ] )
+
def test_999_reset_data_for_later_test_runs( self ):
"""Reseting data to enable later test runs to pass"""
# Logged in as regular_user_12
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.