EduploneExam/tests testProcessResponse.py,NONE,1.1
Nils Haagen <[email protected]>
| Newsgroups | gmane.comp.web.zope.eduplone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/eduplone/EduploneExam/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5147/tests
Added Files:
testProcessResponse.py
Log Message:
testProcessREsponse
--- NEW FILE: testProcessResponse.py ---
#
# Skeleton PloneTestCase
#
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
from Testing import ZopeTestCase
from Products.CMFPlone.tests import PloneTestCase
import common
common.installProducts()
from Products.EduploneExam.registry import getAnswerTypes
from Products.EduploneExam.userresponses import SimpleResponse
from Products.EduploneExam import ExamFolder
from Products.CMFCore.utils import getToolByName
class TestResponse(PloneTestCase.PloneTestCase):
def afterSetUp(self):
common.installWithinPortal(self.portal)
#create examFolder to have the deliverResponse-method implemented
self.portal.invokeFactory('ExamFolder', 'ExamFolder')
examFolder=self.portal.ExamFolder
questid='dummyQuest' #()
examFolder.invokeFactory('MultipleChoiceQuestion', questid)
mchoiceQuest=examFolder[questid]
mcqParam={'title':'Question Title',
'maxScore':10,
'strict':'0'}
for p in mcqParam.keys():
mut=mchoiceQuest.getField(p).getMutator(mchoiceQuest)
mut(mcqParam[p])
mchoiceQuest.invokeFactory('MultipleChoiceAnswer', 'mcA1')
mchoiceQuest.invokeFactory('MultipleChoiceAnswer', 'mcA2')
mchoiceQuest.invokeFactory('MultipleChoiceAnswer', 'mcA3')
mchoiceQuest.invokeFactory('MultipleChoiceAnswer', 'mcA4')
mchoiceQuest.mcA1.setCorrect('1')
mchoiceQuest.mcA2.setCorrect('1')
mchoiceQuest.mcA3.setCorrect('0')
mchoiceQuest.mcA4.setCorrect('0')
def testMChoiceProcessAnswer(self):
#self.loginPortalOwner()
#send REQUEST.response-object to a question
REQresp=''
mchoiceQuest.processResponse(REQresp)
#get back the responseObject:
responseObjBack=examFolder.deliverResponse(mchoiceQuest)
#self.failUnless(responseObjIn==responseObjBack)
#self.portal.manage_delObjects(['ExamFolder'])
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestResponse))
return suite
if __name__ == '__main__':
framework()
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/