From e1d8645415b07af778aac1d535d1601694686318 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 21 Jun 2013 21:48:15 +0200 Subject: [PATCH] fix unit tests for config_install Signed-off-by: Nico Schottelius --- cdist/config_install.py | 10 ++++------ cdist/test/config_install/__init__.py | 18 +++++++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/cdist/config_install.py b/cdist/config_install.py index e5d2de87..db7e3792 100644 --- a/cdist/config_install.py +++ b/cdist/config_install.py @@ -32,17 +32,15 @@ from cdist import core class ConfigInstall(object): """Cdist main class to hold arbitrary data""" - def __init__(self, context): + def __init__(self, context, dry_run=False): self.context = context - self.log = logging.getLogger(self.context.target_host) + self.log = logging.getLogger(self.context.target_host) + self.dry_run = dry_run self.explorer = core.Explorer(self.context.target_host, self.context.local, self.context.remote) self.manifest = core.Manifest(self.context.target_host, self.context.local) - self.code = core.Code(self.context.target_host, self.context.local, self.context.remote) - - # Add switch to disable code execution - self.dry_run = False + self.code = core.Code(self.context.target_host, self.context.local, self.context.remote) def _init_files_dirs(self): """Prepare files and directories for the run""" diff --git a/cdist/test/config_install/__init__.py b/cdist/test/config_install/__init__.py index 2abf7614..83f65575 100644 --- a/cdist/test/config_install/__init__.py +++ b/cdist/test/config_install/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -59,8 +59,8 @@ class ConfigInstallRunTestCase(test.CdistTestCase): exec_path=test.cdist_exec_path, debug=True) - self.context.local.object_path = object_base_path - self.context.local.type_path = type_base_path + self.context.local.object_path = object_base_path + self.context.local.type_path = type_base_path self.config = cdist.config.Config(self.context) @@ -86,15 +86,15 @@ class ConfigInstallRunTestCase(test.CdistTestCase): # First run: # solves first and maybe second (depending on the order in the set) - self.config.stage_run_iterate() + self.config.iterate_once() self.assertTrue(third.state == third.STATE_DONE) - self.config.stage_run_iterate() + self.config.iterate_once() self.assertTrue(second.state == second.STATE_DONE) try: - self.config.stage_run_iterate() + self.config.iterate_once() except cdist.Error: # Allow failing, because the third run may or may not be unecessary already, # depending on the order of the objects @@ -111,9 +111,5 @@ class ConfigInstallRunTestCase(test.CdistTestCase): first.requirements = [second.name] second.requirements = [first.name] - # First round solves __third/moon - self.config.stage_run_iterate() - - # Second round detects it cannot solve the rest with self.assertRaises(cdist.Error): - self.config.stage_run_iterate() + self.config.iterate_until_finished()