From: Frank Brehm Date: Wed, 18 May 2022 11:38:15 +0000 (+0200) Subject: Adding test/test_06_ldapcfg.py for testing module pp_admintools.ldap_config X-Git-Tag: 0.4.2^2~5^2~8 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=d3d0c4d79bfba693a54154e7d2e3b5ac9b3ad137;p=pixelpark%2Fpp-admin-tools.git Adding test/test_06_ldapcfg.py for testing module pp_admintools.ldap_config --- diff --git a/test/test_06_ldapcfg.py b/test/test_06_ldapcfg.py new file mode 100755 index 0000000..5704de8 --- /dev/null +++ b/test/test_06_ldapcfg.py @@ -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