]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding test/test_06_ldapcfg.py for testing module pp_admintools.ldap_config
authorFrank Brehm <frank@brehm-online.com>
Wed, 18 May 2022 11:38:15 +0000 (13:38 +0200)
committerFrank Brehm <frank@brehm-online.com>
Wed, 18 May 2022 11:38:15 +0000 (13:38 +0200)
test/test_06_ldapcfg.py [new file with mode: 0755]

diff --git a/test/test_06_ldapcfg.py b/test/test_06_ldapcfg.py
new file mode 100755 (executable)
index 0000000..5704de8
--- /dev/null
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+'''
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2022 by Frank Brehm, Berlin
+@license: GPL3
+@summary: test script (and module) for unit tests on LDAP config class
+'''
+
+import os
+import sys
+import logging
+
+from pathlib import Path
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+# from babel.dates import LOCALTZ
+
+libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib'))
+sys.path.insert(0, libdir)
+
+from general import PpAdminToolsTestcase, get_arg_verbose, init_root_logger
+
+from fb_tools.common import pp, to_str, is_sequence
+
+LOG = logging.getLogger('test-ldapcfg')
+
+
+# =============================================================================
+class TestLdapConfig(PpAdminToolsTestcase):
+
+    # -------------------------------------------------------------------------
+    def setUp(self):
+
+        self.test_dir = Path(__file__).parent.resolve()
+        self.base_dir = self.test_dir.parent
+        self.test_cfg_dir = self.test_dir / 'test-ldapconfig'
+        self._appname = 'test-ldapcfg'
+
+    # -------------------------------------------------------------------------
+    def tearDown(self):
+
+        pass
+
+    # -------------------------------------------------------------------------
+    def test_import(self):
+
+        LOG.info("Testing import of pp_admintools.ldap_config ...")
+        import pp_admintools.ldap_config
+        LOG.debug(
+            "Version of pp_admintools.ldap_config: " + pp_admintools.ldap_config.__version__)
+
+        LOG.info("Testing import of LdapConfigError from pp_admintools.ldap_config ...")
+        from pp_admintools.ldap_config import LdapConfigError               # noqa
+
+        LOG.info("Testing import of LdapConnectionInfo from pp_admintools.ldap_config ...")
+        from pp_admintools.ldap_config import LdapConnectionInfo                # noqa
+
+        LOG.info("Testing import of LdapConfiguration from pp_admintools.ldap_config ...")
+        from pp_admintools.ldap_config import LdapConfiguration                 # noqa
+
+    # -------------------------------------------------------------------------
+    def test_object(self):
+
+        LOG.info("Testing init of a LdapConfiguration object.")
+
+        from pp_admintools.ldap_config import LdapConfiguration
+
+        cfg = LdapConfiguration(
+            appname=self.appname,
+            config_dir='test', additional_stems='test',
+            verbose=self.verbose,
+        )
+        LOG.debug("LdapConfiguration %%r: %r", cfg)
+        LOG.debug("LdapConfiguration %%s: %s", str(cfg))
+
+
+# =============================================================================
+if __name__ == '__main__':
+
+    verbose = get_arg_verbose()
+    if verbose is None:
+        verbose = 0
+    init_root_logger(verbose)
+
+    LOG.info("Starting tests ...")
+
+    suite = unittest.TestSuite()
+
+    suite.addTest(TestLdapConfig('test_import', verbose))
+    suite.addTest(TestLdapConfig('test_object', verbose))
+
+    runner = unittest.TextTestRunner(verbosity=verbose)
+
+    result = runner.run(suite)
+
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4