From df8be73c109499f406ac0f6d1a4d1fb91f0f5257 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Oct 2011 23:18:58 +0200 Subject: [PATCH 1/2] test for debug in manifest Signed-off-by: Nico Schottelius --- lib/cdist/test/manifest/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/cdist/test/manifest/__init__.py b/lib/cdist/test/manifest/__init__.py index 879c4c1a..86885a59 100644 --- a/lib/cdist/test/manifest/__init__.py +++ b/lib/cdist/test/manifest/__init__.py @@ -26,9 +26,7 @@ import getpass import shutil import string import random - -#import logging -#logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s') +import logging import cdist from cdist.exec import local @@ -51,12 +49,13 @@ class ManifestTestCase(unittest.TestCase): def setUp(self): self.temp_dir = self.mkdtemp() - target_host = 'localhost' + self.target_host = 'localhost' out_path = self.temp_dir - self.local = local.Local(target_host, local_base_path, out_path) + self.local = local.Local(self.target_host, local_base_path, out_path) self.local.create_directories() self.local.link_emulator(cdist.test.cdist_exec_path) - self.manifest = manifest.Manifest(target_host, self.local) + self.manifest = manifest.Manifest(self.target_host, self.local) + self.log = logging.getLogger("cdist") def tearDown(self): shutil.rmtree(self.temp_dir) @@ -69,3 +68,8 @@ class ManifestTestCase(unittest.TestCase): cdist_type = core.Type(self.local.type_path, '__dump_environment') cdist_object = core.Object(cdist_type, self.local.object_path, 'whatever') self.manifest.run_type_manifest(cdist_object) + + def test_debug_env_setup(self): + self.log.setLevel(logging.DEBUG) + manifest = cdist.core.manifest.Manifest(self.target_host, self.local) + self.assertTrue("__debug" in manifest.env) From ba59339f67efda5f8f2a81870e25a99b6153146d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 14 Oct 2011 23:21:22 +0200 Subject: [PATCH 2/2] fixup code and manifest Signed-off-by: Nico Schottelius --- lib/cdist/core/manifest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cdist/core/manifest.py b/lib/cdist/core/manifest.py index 3eca166c..f031ac35 100644 --- a/lib/cdist/core/manifest.py +++ b/lib/cdist/core/manifest.py @@ -74,6 +74,9 @@ class Manifest(object): '__global': self.local.out_path, '__cdist_type_base_path': self.local.type_path, # for use in type emulator } + if log.getEffectiveLevel() == logging.DEBUG: + self.env.update({'__debug': "yes" }) + def run_initial_manifest(self, script): env = os.environ.copy()