I'm having some problems with a test case I'm trying to write, and I
can't figure out why it is failing. It appears that identity isn't
initializing, but identity works properly in other test cases, and I
was hoping someone might have some ideas as to why.
Some pertinent system info:
Turbogears svn 0.9a9dev-r1953
SqlAlchemy 0.2.8
Here is what I hope is pertinent:
database.set_db_uri('sqlite:///:memory:', 'sqlalchemy')
session = database.session
config.update({'global': {
'identity.provider': '${identity}',
'visit.saprovider.model':'${package}.model.Visit',
'identity.saprovider.model.user':"${package}.model.User",
'identity.saprovider.model.group':"${package}.model.Group",
'identity.saprovider.model.permission':"${package}.model.Permission",
'identity.saprovider.model.visit':"${package}.model.VisitIdentity"
}})
class TestRegistration(unittest.TestCase, SharedMethods):
def setUp(self):
database.create_session()
self.create_identity_tables()
register_model.create_registration_tables()
cherrypy.root = None
cherrypy.tree.mount_points = {}
cherrypy.tree.mount(RegTestController(), '/')
config.update({'global':{'registration.verified_user.groups':[],
'registration.unverified_user.groups':[] }
})
def tearDown(self):
database.rollback_all()
self.drop_identity_tables()
self.drop_registration_tables()
#testutil.sqlalchemy_cleanup()
startup.stopTurboGears()
# This test passes...
def test_new_registration(self):
"A new pending user is created."
self.create_pending_user_by_request()
self.assert_ok_response()
assert getattr(cherrypy.request, 'identity', None)
pend = RegistrationPendingUser.get_by_email_address(test_email)
assert(pend.user_name=='dschrute')
assert(register_model.user_class_finder.user_class.select().count('*')==0)
#This test fails
def test_pending_user_groups(self):
"A unvalidated user is made a real user in the unvalidated
group(s)."
# create the group
g_visit = model.Group(group_name='dojo_visitors',
display_name='Visitors to the dojo')
g_member = model.Group(group_name='dojo_members',
display_name='Members of the dojo')
config.update({'global':{'registration.unverified_user.groups':['dojo_visitors'],
'registration.verified_user.groups':['dojo_members']}})
session.flush([g_visit, g_member])
assert session.query(model.Group).count()==2
self.create_pending_user_by_request()
assert getattr(cherrypy.request, 'identity', None) #Fails
with this assertion
class SharedMethods(object):
"Container for methods that can be shared in SQLAlchemy and
SQLObject test cases."
def create_pending_user_by_request(self):
req_str =
''.join(['/register/create?user_name=%s&email=%s&email2=%s',
'&display_name=%s&password1=%s&password2=%s']) % \
('dschrute', test_email, test_email,
'Dwight+Schrute',
'secret', 'secret')
testutil.createRequest(req_str)
def assert_ok_response(self):
if cherrypy.response.status != '200 OK':
raise AssertionError, cherrypy.response.body[0]
As I read the code, it appears that the call to testutil.createRequest
should handle starting turbogears and starting all the extensions. So,
I'm not sure what I am missing. If anyone has any ideas, it would be
very useful. I've been looking at this for too long. Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---