EduploneExam/tests testRegistry.py,NONE,1.1
Jens Klein <[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-serv23459/tests
Added Files:
testRegistry.py
Log Message:
itest the registry
--- NEW FILE: testRegistry.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.Archetypes.public import BaseContent
from Products.EduploneExam.interfaces.IExamQuestion import IExamQuestion
from Products.EduploneExam.registry import registerQuestionType
from Products.EduploneExam.registry import getQuestionTypes
# crash test dummies
class dummyclasspositive(BaseContent):
__implements__ = (IExamQuestion,)
def processResponse():
pass
class dummyclassnegative(BaseContent):
pass
# test classes
class TestRegistry(PloneTestCase.PloneTestCase):
def afterSetUp(self):
pass
def testRegisterImplementingClass(self):
# Test if the registry accepts a class implementing IExamQuestion
registerQuestionType(dummyclasspositive)
# should not raise a exception!
questions= getQuestionTypes()
self.failUnless(dummyclasspositive.__name__ in questions)
def testRegisterNotImplementingClass(self):
# Test if the registry rejects a class not implementing IExamQuestion
try:
registerQuestionType(dummyclassnegative)
except NotImplementedError:
#desired behavior
return
raise AssertionError('registry should raise NotImplementedError!')
def test_suite():
from unittest import TestSuite, makeSuite
suite = TestSuite()
suite.addTest(makeSuite(TestRegistry))
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/