Commit e6e68594 authored by Lorenz Steinert's avatar Lorenz Steinert

added module docstrings

parent 186992cb
......@@ -7,8 +7,10 @@ import ldap3 as ldap
from esme import FsrLdap, get_fallback_fsr, get_fallback_fsr_extern, get_sprecher, get_protokollant
class FsrLdapTest(unittest.TestCase):
"""test the functions with ldap"""
def setUp(self):
"""setup for the tests"""
self.test_ldap_server = FsrLdap('test_server', 'dc=test,dc=de')
conn = ldap.Connection(self.test_ldap_server.server, client_strategy=ldap.MOCK_SYNC)
conn.strategy.add_entry('ou=people,'+self.test_ldap_server.base, {})
......@@ -35,32 +37,39 @@ class FsrLdapTest(unittest.TestCase):
self.sharedir = "/tmp/python3-esme-testing"
def test_get_fsr_ldap(self):
"""test the get_fsr_ldap function"""
self.assertEqual(self.test_ldap_server.get_fsr_ldap(self.sharedir, testing=True),
['testing test1', 'testing test2', 'testing test3'])
def test_get_fsr_extern_ldap(self):
"""test the get_fsr_extern_ldap function"""
self.assertEqual(self.test_ldap_server.get_fsr_extern_ldap(self.sharedir, testing=True),
['testing test4', 'testing test5', 'testing test6'])
def test_get_fsr_ldap_no_server(self):
"""test the get_fsr_ldap function without ldap connection"""
self.test_ldap_server.server = ""
self.assertEqual(self.test_ldap_server.get_fsr_ldap(self.sharedir, testing=True),
[])
def test_get_fsr_extern_ldap_no_server(self):
"""test the get_fst_extern_ldap function without ldap connection"""
self.test_ldap_server.server = ""
self.assertEqual(self.test_ldap_server.get_fsr_extern_ldap(self.sharedir, testing=True),
[])
def tearDown(self):
"""cleanup after the tests"""
os.remove("/tmp/python3-esme-testing/fsr")
os.remove("/tmp/python3-esme-testing/fsr_extern")
os.rmdir("/tmp/python3-esme-testing")
class GetFuncTest(unittest.TestCase):
"""a"""
"""test case for the get methods without ldap"""
def setUp(self):
"""setup for the tests"""
os.mkdir("/tmp/python3-esme-testing")
with open("/tmp/python3-esme-testing/fsr", 'w') as fobj:
fobj.write("testing test1\n")
......@@ -71,37 +80,44 @@ class GetFuncTest(unittest.TestCase):
@staticmethod
def input_test(arg):
"""override for the std input method"""
return "testinginput"
@staticmethod
def input_test2(arg):
"""override for the std input method"""
return ""
def test_get_fallback_fsr(self):
"""test the get_fallback_fsr function"""
sharedir = "/tmp/python3-esme-testing"
self.assertEqual(get_fallback_fsr(sharedir), ['testing test1'])
os.remove("/tmp/python3-esme-testing/fsr")
self.assertEqual(get_fallback_fsr(sharedir), [])
def test_get_fallback_fsr_extern(self):
"""test the get_fallback_fsr_extern function"""
sharedir = "/tmp/python3-esme-testing"
self.assertEqual(get_fallback_fsr_extern(sharedir), ['testing test2'])
os.remove("/tmp/python3-esme-testing/fsr_extern")
self.assertEqual(get_fallback_fsr_extern(sharedir), [])
def test_get_sprcher(self):
"""test the get_sprecher function"""
self.assertEqual(get_sprecher(self.config, self.input_test), "testinginput")
self.assertEqual(get_sprecher(self.config, self.input_test2), "testsprecher")
self.assertEqual(get_sprecher(getinput=self.input_test), "testinginput")
self.assertEqual(get_sprecher(getinput=self.input_test2), "")
def test_get_protokollant(self):
"""test the get_protokollant function"""
self.assertEqual(get_protokollant(self.config, self.input_test), "testinginput")
self.assertEqual(get_protokollant(self.config, self.input_test2), "testprotokollant")
self.assertEqual(get_protokollant(getinput=self.input_test), "testinginput")
self.assertEqual(get_protokollant(getinput=self.input_test2), "")
def tearDown(self):
"""cleanup after tests"""
if os.path.isfile('/tmp/python3-esme-testing/fsr'):
os.remove("/tmp/python3-esme-testing/fsr")
if os.path.isfile('/tmp/python3-esme-testing/fsr_extern'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment