From: Frank Brehm Date: Tue, 19 Mar 2024 09:32:53 +0000 (+0100) Subject: Make the linter happy X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=049c978682d416db7b14cf2a4962bb7440ed0ad2;p=pixelpark%2Fpp-admin-tools.git Make the linter happy --- diff --git a/test/test_05_mailcfg.py b/test/test_05_mailcfg.py index 47f6741..7e19d3e 100755 --- a/test/test_05_mailcfg.py +++ b/test/test_05_mailcfg.py @@ -1,17 +1,18 @@ #!/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: @@ -33,9 +34,13 @@ LOG = logging.getLogger('test-mailcfg') # ============================================================================= 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 @@ -44,27 +49,30 @@ class TestMailConfig(PpAdminToolsTestcase): # ------------------------------------------------------------------------- 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 @@ -73,8 +81,8 @@ class TestMailConfig(PpAdminToolsTestcase): 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)) # ============================================================================= @@ -85,7 +93,7 @@ if __name__ == '__main__': verbose = 0 init_root_logger(verbose) - LOG.info("Starting tests ...") + LOG.info('Starting tests ...') suite = unittest.TestSuite() @@ -99,4 +107,4 @@ if __name__ == '__main__': # ============================================================================= -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list diff --git a/test/test_20_postfix_chain.py b/test/test_20_postfix_chain.py new file mode 100755 index 0000000..49fd0ea --- /dev/null +++ b/test/test_20_postfix_chain.py @@ -0,0 +1,133 @@ +#!/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