Commit 186992cb authored by Lorenz Steinert's avatar Lorenz Steinert

added tests for the get methods

parent f6163c64
......@@ -4,7 +4,7 @@
import os
import unittest
import ldap3 as ldap
from esme import FsrLdap
from esme import FsrLdap, get_fallback_fsr, get_fallback_fsr_extern, get_sprecher, get_protokollant
class FsrLdapTest(unittest.TestCase):
......@@ -34,7 +34,6 @@ class FsrLdapTest(unittest.TestCase):
open("/tmp/python3-esme-testing/fsr_extern", 'a').close()
self.sharedir = "/tmp/python3-esme-testing"
def test_get_fsr_ldap(self):
self.assertEqual(self.test_ldap_server.get_fsr_ldap(self.sharedir, testing=True),
['testing test1', 'testing test2', 'testing test3'])
......@@ -58,5 +57,56 @@ class FsrLdapTest(unittest.TestCase):
os.remove("/tmp/python3-esme-testing/fsr_extern")
os.rmdir("/tmp/python3-esme-testing")
class GetFuncTest(unittest.TestCase):
"""a"""
def setUp(self):
os.mkdir("/tmp/python3-esme-testing")
with open("/tmp/python3-esme-testing/fsr", 'w') as fobj:
fobj.write("testing test1\n")
with open("/tmp/python3-esme-testing/fsr_extern", 'w') as fobj:
fobj.write("testing test2")
self.config = {'PROTOKOLL': {'Sprecher': 'testsprecher',
'Protokollant': 'testprotokollant'}}
@staticmethod
def input_test(arg):
return "testinginput"
@staticmethod
def input_test2(arg):
return ""
def test_get_fallback_fsr(self):
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):
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):
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):
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):
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'):
os.remove("/tmp/python3-esme-testing/fsr_extern")
os.rmdir("/tmp/python3-esme-testing")
if __name__ == "__main__":
unittest.main()
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