1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

adding unit tests for exception while loading module

This commit is contained in:
kakwa 2015-05-20 14:46:29 +02:00
parent 1e5f057e36
commit e769aed10e

View File

@ -44,6 +44,9 @@ def loadconf(configfile, instance):
cherrypy.config.update(configfile) cherrypy.config.update(configfile)
instance.reload(app.config) instance.reload(app.config)
class BadModule():
pass
class TestError(object): class TestError(object):
def testNominal(self): def testNominal(self):
@ -51,6 +54,30 @@ class TestError(object):
loadconf('./tests/cfg/ldapcherry.ini', app) loadconf('./tests/cfg/ldapcherry.ini', app)
return True return True
def testMissingBackendModule(self):
app = LdapCherry()
loadconf('./tests/cfg/ldapcherry.ini', app)
cfg = {'backends': {'ldap.module': 'dontexists'}}
try:
app._init_backends(cfg)
except BackendModuleLoadingFail:
return
else:
raise AssertionError("expected an exception")
def testInitgBackendModuleFail(self):
app = LdapCherry()
loadconf('./tests/cfg/ldapcherry.ini', app)
cfg = {'backends': {'ldap.module': 'ldapcherry.backend'}}
try:
app._init_backends(cfg)
except BackendModuleInitFail:
return
else:
raise AssertionError("expected an exception")
def testLog(self): def testLog(self):
app = LdapCherry() app = LdapCherry()
cfg = { 'global' : {}} cfg = { 'global' : {}}