From ed86ff388c37b51ec814a341dffd432c1f05ce8a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 18 May 2022 13:23:35 +0200 Subject: [PATCH] Adding test/test_05_mailcfg.py for testing module pp_admintools.mail_config --- test/test_05_mailcfg.py | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 test/test_05_mailcfg.py diff --git a/test/test_05_mailcfg.py b/test/test_05_mailcfg.py new file mode 100755 index 0000000..530ab98 --- /dev/null +++ b/test/test_05_mailcfg.py @@ -0,0 +1,102 @@ +#!/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 mail 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-mailcfg') + + +# ============================================================================= +class TestMailConfig(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-mailconfig' + self._appname = 'test-mailcfg' + + # ------------------------------------------------------------------------- + def tearDown(self): + + pass + + # ------------------------------------------------------------------------- + def test_import(self): + + LOG.info("Testing import of pp_admintools.mail_config ...") + import pp_admintools.mail_config + LOG.debug( + "Version of pp_admintools.mail_config: " + pp_admintools.mail_config.__version__) + + LOG.info("Testing import of MailConfigError from pp_admintools.mail_config ...") + from pp_admintools.mail_config import MailConfigError # noqa + + LOG.info("Testing import of MailConfiguration from pp_admintools.mail_config ...") + from pp_admintools.mail_config import MailConfiguration # noqa + + # ------------------------------------------------------------------------- + def test_object(self): + + LOG.info("Testing init of a MailConfiguration object.") + + from pp_admintools.mail_config import MailConfiguration + + cfg = MailConfiguration( + appname=self.appname, + config_dir='test', additional_stems='test', + verbose=self.verbose, + ) + LOG.debug("MailConfiguration %%r: %r", cfg) + LOG.debug("MailConfiguration %%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(TestMailConfig('test_import', verbose)) + suite.addTest(TestMailConfig('test_object', verbose)) + + runner = unittest.TextTestRunner(verbosity=verbose) + + result = runner.run(suite) + + +# ============================================================================= + +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 -- 2.39.5