]> Frank Brehm's Git Trees - pixelpark/puppet-tools.git/commitdiff
Extending tests
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 7 Feb 2023 14:52:35 +0000 (15:52 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 7 Feb 2023 14:52:35 +0000 (15:52 +0100)
test/test-config/puppet-tools.yaml
test/test_10_config.py
test/test_15_base_app.py

index c0afc3018f423f489ad7e8fa69a05b9df185d891..ea89d6266cdb0cbedfd715fd0eb57740c73ef431 100644 (file)
@@ -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
index c3204d1a96c18cf34a91194fa5aca935f9ad9d85..6a47f7495d4b927ffc6101a052d54472347695e7 100755 (executable)
@@ -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__':
index ade1b12aaaa2ec719ebd98fe06f34725aac1b4b6..3bd1ff44b03a06c99b0b60b8eb8a8dd228f548fd 100755 (executable)
@@ -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))
 
 
 # =============================================================================