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:
parent
1e5f057e36
commit
e769aed10e
@ -44,6 +44,9 @@ def loadconf(configfile, instance):
|
||||
cherrypy.config.update(configfile)
|
||||
instance.reload(app.config)
|
||||
|
||||
class BadModule():
|
||||
pass
|
||||
|
||||
class TestError(object):
|
||||
|
||||
def testNominal(self):
|
||||
@ -51,6 +54,30 @@ class TestError(object):
|
||||
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||
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):
|
||||
app = LdapCherry()
|
||||
cfg = { 'global' : {}}
|
||||
|
Loading…
Reference in New Issue
Block a user