#!/usr/bin/env python
# -*- coding: utf-8 -*-
-'''
+"""
+@summary: Test script (and module) for unit tests on mail config class.
+
@author: Frank Brehm
@contact: frank.brehm@pixelpark.com
-@copyright: © 2022 by Frank Brehm, Berlin
+@copyright: © 2023 by Frank Brehm, Berlin
@license: GPL3
-@summary: test script (and module) for unit tests on mail config class
-'''
+"""
+import logging
import os
import sys
-import logging
-
+import textwrap
from pathlib import Path
try:
# =============================================================================
class TestMailConfig(PpAdminToolsTestcase):
+ """Testcase for unit tests on mail config objects."""
# -------------------------------------------------------------------------
def setUp(self):
+ """Execute this on setting up before calling each particular test method."""
+ if self.verbose >= 1:
+ print()
self.test_dir = Path(__file__).parent.resolve()
self.base_dir = self.test_dir.parent
# -------------------------------------------------------------------------
def tearDown(self):
-
+ """Execute this after calling each particular test method."""
pass
# -------------------------------------------------------------------------
def test_import(self):
-
- LOG.info("Testing import of pp_admintools.config.mail ...")
+ """Test importing module pp_admintools.config.mail."""
+ LOG.info('Testing import of pp_admintools.config.mail ...')
import pp_admintools.config.mail
LOG.debug(
- "Version of pp_admintools.config.mail: " + pp_admintools.config.mail.__version__)
+ 'Version of pp_admintools.config.mail: ' + pp_admintools.config.mail.__version__)
- LOG.info("Testing import of MailConfigError from pp_admintools.config.mail ...")
- from pp_admintools.config.mail import MailConfigError # noqa
+ LOG.info('Testing import of MailConfigError from pp_admintools.config.mail ...')
+ from pp_admintools.config.mail import MailConfigError
+ LOG.debug('Description of MailConfigError: ' + textwrap.dedent(MailConfigError.__doc__))
- LOG.info("Testing import of MailConfiguration from pp_admintools.config.mail ...")
- from pp_admintools.config.mail import MailConfiguration # noqa
+ LOG.info('Testing import of MailConfiguration from pp_admintools.config.mail ...')
+ from pp_admintools.config.mail import MailConfiguration
+ LOG.debug(
+ 'Description of MailConfiguration: ' + textwrap.dedent(MailConfiguration.__doc__))
# -------------------------------------------------------------------------
def test_object(self):
-
- LOG.info("Testing init of a MailConfiguration object.")
+ """Test init of a MailConfiguration object."""
+ LOG.info('Testing init of a MailConfiguration object.')
from pp_admintools.config.mail import MailConfiguration
config_dir='test', additional_stems='test',
verbose=self.verbose,
)
- LOG.debug("MailConfiguration %%r: %r", cfg)
- LOG.debug("MailConfiguration %%s: %s", str(cfg))
+ LOG.debug('MailConfiguration %%r: %r', cfg)
+ LOG.debug('MailConfiguration %%s: %s', str(cfg))
# =============================================================================
verbose = 0
init_root_logger(verbose)
- LOG.info("Starting tests ...")
+ LOG.info('Starting tests ...')
suite = unittest.TestSuite()
# =============================================================================
-# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@summary: Test script (and module) for unit tests on postfix chain objects.
+
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2024 by Frank Brehm, Berlin
+@license: GPL3
+"""
+
+import logging
+import os
+import sys
+import textwrap
+
+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
+
+APPNAME = 'test-postfix-chain'
+LOG = logging.getLogger(APPNAME)
+
+
+# =============================================================================
+class TestPostfixChain(PpAdminToolsTestcase):
+ """Testcase for unit tests on postfix chain objects."""
+
+ # -------------------------------------------------------------------------
+ def setUp(self):
+ """Execute this on setting up before calling each particular test method."""
+ if self.verbose >= 1:
+ print()
+
+ self._appname = APPNAME
+
+ # -------------------------------------------------------------------------
+ def tearDown(self):
+ """Execute this after calling each particular test method."""
+ pass
+
+ # -------------------------------------------------------------------------
+ def test_import(self):
+ """Test importing module pp_admintools.postfix_chain."""
+ LOG.info('Testing import of pp_admintools.postfix_chain ...')
+ import pp_admintools.postfix_chain
+ LOG.debug(
+ 'Version of pp_admintools.postfix_chain: ' + pp_admintools.postfix_chain.__version__)
+
+ LOG.info('Testing import of PostfixLogchainInfo from pp_admintools.postfix_chain ...')
+ from pp_admintools.postfix_chain import PostfixLogchainInfo
+ LOG.debug(
+ 'Description of PostfixLogchainInfo: ' + textwrap.dedent(PostfixLogchainInfo.__doc__))
+
+ # -------------------------------------------------------------------------
+ def test_empty_object(self):
+ """Test init of an empty PostfixLogchainInfo object."""
+ LOG.info('Testing init of an empty PostfixLogchainInfo object.')
+
+ from pp_admintools.postfix_chain import PostfixLogchainInfo
+
+ chain = PostfixLogchainInfo()
+ LOG.debug('PostfixLogchainInfo %r: {!r}'.format(chain))
+ LOG.debug('PostfixLogchainInfo %s:\n{}'.format(chain))
+
+ # -------------------------------------------------------------------------
+ def test_filled_object(self):
+ """Test init of a filled PostfixLogchainInfo object."""
+ LOG.info('Testing init of a filled PostfixLogchainInfo object.')
+
+ from pp_admintools.postfix_chain import PostfixLogchainInfo
+
+ msg_id = (
+ '?UTF-8?Q?<1710519839.f17fa533d20bd08ffac42a6b32f1383f'
+ '@sparkassen-finanzportal.de>?='
+ )
+
+ chain = PostfixLogchainInfo(
+ client_host='mail.uhu-banane.de',
+ client_addr='188.34.187.246',
+ start='2024-03-15T17:24:52.816303+01:00',
+ end='2024-03-15T17:24:53.304534+01:00',
+ message_id=msg_id,
+ postfix_pid='23456',
+ ehlo='2',
+ starttls='0/1',
+ sent_quit='1',
+ auth='0/1',
+ commands='2/3',
+ rcpt='2',
+ data='3',
+ mail=1,
+ from_address='frank.brehm@pixelpark.com',
+ to_address='frank@brehm-online.com',
+ )
+ LOG.debug('PostfixLogchainInfo %r: {!r}'.format(chain))
+ LOG.debug('PostfixLogchainInfo %s:\n{}'.format(chain))
+
+
+# =============================================================================
+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(TestPostfixChain('test_import', verbose))
+ suite.addTest(TestPostfixChain('test_empty_object', verbose))
+ suite.addTest(TestPostfixChain('test_filled_object', verbose))
+
+ runner = unittest.TextTestRunner(verbosity=verbose)
+
+ result = runner.run(suite)
+
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list