Back to index

plone3  3.1.7
PloneTestCase.py
Go to the documentation of this file.
00001 #
00002 # PloneTestCase
00003 #
00004 
00005 # $Id: PloneTestCase.py 20147 2008-03-28 23:49:46Z witsch $
00006 
00007 from Products.PloneTestCase.ptc import *
00008 
00009 # Make the test fixture extension profile active
00010 from zope.interface import classImplements
00011 from Products.CMFPlone.Portal import PloneSite
00012 from Products.CMFPlone.interfaces import ITestCasePloneSiteRoot
00013 classImplements(PloneSite, ITestCasePloneSiteRoot)
00014 
00015 setupPloneSite(extension_profiles=['Products.CMFPlone:testfixture'])
00016 
00017 from plone.protect.authenticator import AuthenticatorView
00018 from re import match
00019 
00020 
00021 class PloneTestCase(PloneTestCase):
00022     """This is a stub now, but in case you want to try
00023        something fancy on Your Branch (tm), put it here.
00024     """
00025 
00026     def setRequestMethod(self, method):
00027         self.app.REQUEST.set('REQUEST_METHOD', method)
00028         self.app.REQUEST.method = method
00029 
00030     def getAuthenticator(self):
00031         tag = AuthenticatorView('context', 'request').authenticator()
00032         pattern = '<input .*name="(\w+)".*value="(\w+)"'
00033         return match(pattern, tag).groups()
00034 
00035     def setupAuthenticator(self):
00036         name, token = self.getAuthenticator()
00037         self.app.REQUEST.form[name] = token
00038 
00039 
00040 class FunctionalTestCase(Functional, PloneTestCase):
00041     """This is a stub now, but in case you want to try
00042        something fancy on Your Branch (tm), put it here.
00043     """