From: Frank Brehm Date: Tue, 7 Feb 2023 14:52:35 +0000 (+0100) Subject: Extending tests X-Git-Tag: 0.3.0~2^2~71 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=e648a768bde7361e15bd54c8a92790737e4ab5ce;p=pixelpark%2Fpuppet-tools.git Extending tests --- diff --git a/test/test-config/puppet-tools.yaml b/test/test-config/puppet-tools.yaml index c0afc30..ea89d62 100644 --- a/test/test-config/puppet-tools.yaml +++ b/test/test-config/puppet-tools.yaml @@ -9,3 +9,10 @@ common: puppet: deploy_root: /etc/puppetlabs/filesdir +mail: + from: puppet@pixelpark.com + to: + - frank@brehm-online.com + - frank.brehm@pixelpark.com + cc: + - solution@pixelpark.com diff --git a/test/test_10_config.py b/test/test_10_config.py index c3204d1..6a47f74 100755 --- a/test/test_10_config.py +++ b/test/test_10_config.py @@ -74,8 +74,9 @@ class TestConfig(DpxPuppetToolsTestcase): additional_cfgdirs=self.test_cfg_dir, additional_stems='test', verbose=self.verbose, ) - LOG.debug("DpxPuppetConfig %%r: %r", cfg) - LOG.debug("DpxPuppetConfig %%s:\n%s", str(cfg)) + LOG.debug("DpxPuppetConfig %%r: {!r}".format(cfg)) + if self.verbose > 2: + LOG.debug("DpxPuppetConfig %%s:\n{}".format(cfg)) # ------------------------------------------------------------------------- def test_read_config(self): @@ -117,6 +118,22 @@ class TestConfig(DpxPuppetToolsTestcase): self.assertIsInstance(value_got, Path) self.assertEqual(value_got, expected) + test_data = ( + ('mail_from', 'puppet@pixelpark.com'), + ('mail_recipients', ['frank@brehm-online.com', 'frank.brehm@pixelpark.com']), + ('mail_cc', ['solution@pixelpark.com']), + ('reply_to', 'solution@pixelpark.com'), + ('mail_method', 'sendmail'), + ) + + for pair in test_data: + prop_name = pair[0] + expected = pair[1] + LOG.debug("Expecting cfg.{k}: {exp!r}.".format(k=prop_name, exp=expected)) + value_got = getattr(cfg, prop_name) + LOG.debug("Got cfg.{k}: {val!r}.".format(k=prop_name, val=value_got)) + self.assertEqual(value_got, expected) + # ============================================================================= if __name__ == '__main__': diff --git a/test/test_15_base_app.py b/test/test_15_base_app.py index ade1b12..3bd1ff4 100755 --- a/test/test_15_base_app.py +++ b/test/test_15_base_app.py @@ -12,6 +12,8 @@ import os import sys import logging +from pathlib import Path + try: import unittest2 as unittest except ImportError: @@ -29,7 +31,10 @@ class TestBaseApp(DpxPuppetToolsTestcase): # ------------------------------------------------------------------------- def setUp(self): - pass + self.test_dir = Path(__file__).parent.resolve() + self.base_dir = self.test_dir.parent + self.test_cfg_dir = self.test_dir / 'test-config' + self._appname = 'test_app' # ------------------------------------------------------------------------- def test_import(self): @@ -50,16 +55,18 @@ class TestBaseApp(DpxPuppetToolsTestcase): quiet = True app = BaseDPXPuppetApplication( - appname=self.appname, quiet=quiet, verbose=self.verbose) + appname=self.appname, quiet=quiet, verbose=self.verbose, + additional_cfgdirs=self.test_cfg_dir) LOG.debug("Drawing lines ...") app.empty_line() app.line(linechar='#', color='CYAN') app.line(width=20) - LOG.debug("BaseDPXPuppetApplication %%r: %r", app) + LOG.debug("BaseDPXPuppetApplication %%r: {!r}".format(app)) app.empty_line() - LOG.debug("BaseDPXPuppetApplication %%s: %s", str(app)) + if self.verbose > 2: + LOG.debug("BaseDPXPuppetApplication %%s:\n{}".format(app)) # =============================================================================